Local Development Setup
This guide will help you set up a local development environment for the My Marketing Pro application.
Prerequisites
Section titled “Prerequisites”- PHP 7.4+: Built-in PHP development server
- MySQL 8.0: Database server (via Homebrew on macOS)
- Git: Version control
- SSH Access: Configured access to production server
Installation Steps
Section titled “Installation Steps”1. Install MySQL via Homebrew
Section titled “1. Install MySQL via Homebrew”# Install MySQLbrew install mysql
# Start MySQL servicebrew services start mysql
# Verify it's runningbrew services list | grep mysql2. Create Local Database
Section titled “2. Create Local Database”# Connect to MySQLmysql -u root
# Create the databaseCREATE DATABASE mmp_app;
# Exit MySQLexit3. Clone the Repository
Section titled “3. Clone the Repository”cd ~/Desktop/mmpgit clone https://github.com/my-marketing-pro/mmp-webapp.gitcd mmp-webapp4. Import Database Schema
Section titled “4. Import Database Schema”Use the Makefile command to sync the production database schema to your local environment:
# Full sync: export from production and import locallymake db-syncOr do it manually:
# Export from productionmake db-export
# Import to localmake db-import5. Configure Environment
Section titled “5. Configure Environment”The application auto-detects whether you’re running locally or in production based on the hostname.
Check your config files:
config.php- Main configurationincludes/config.php- Additional configurationincludes/db.php- Database connection
These files already have localhost detection built in:
if ($_SERVER['HTTP_HOST'] === 'localhost' || strpos($_SERVER['HTTP_HOST'], 'localhost:') === 0) { $host = 'localhost'; $db = 'mmp_app'; $user = 'root'; $pass = '';}Running the Development Server
Section titled “Running the Development Server”Start PHP Development Server
Section titled “Start PHP Development Server”# Start server on http://localhost:8000make server
# Or manually:php -S localhost:8000Access the Application
Section titled “Access the Application”Open your browser and navigate to:
- Main App: http://localhost:8000
- Dashboard: http://localhost:8000/app-dashboard.php
- Auth: http://localhost:8000/app-auth.php
Database Management
Section titled “Database Management”Start/Stop MySQL
Section titled “Start/Stop MySQL”# Start MySQLmake db-start
# Stop MySQLmake db-stopSync Database Schema
Section titled “Sync Database Schema”# Sync production schema to localmake db-syncManual Database Access
Section titled “Manual Database Access”# Connect to local databasemysql -u root mmp_app
# Check tablesSHOW TABLES;
# View database structureDESCRIBE app_users;Troubleshooting
Section titled “Troubleshooting”Port Already in Use
Section titled “Port Already in Use”If port 8000 is already in use:
# Use a different portphp -S localhost:8001MySQL Connection Error
Section titled “MySQL Connection Error”Check if MySQL is running:
brew services list | grep mysqlIf it’s not running:
brew services start mysqlDatabase Import Errors
Section titled “Database Import Errors”If the database import fails, check that:
- MySQL is running
- The database
mmp_appexists - The schema file exists at
/tmp/mmp_app_schema.sql
# Verify file existsls -lh /tmp/mmp_app_schema.sql
# Check database existsmysql -u root -e "SHOW DATABASES LIKE 'mmp_app';"Next Steps
Section titled “Next Steps”- Database Structure - Understand the database schema
- Git Workflow - Learn the Git workflow
- Makefile Commands - Quick command reference