This repository provides a robust and flexible development setup for any PHP-based project (Laravel, Symfony, WordPress, etc.) using Docker, with full support for:
- β Multiple PHP versions (5.6, 7.4β8.3)
- β
Virtual host management via
sites-available/sites-enabled - β Composer and Xdebug (where supported)
- β MySQL or PostgreSQL selectable per project
- β Redis support
- β Node.js support for frontend tools (Vite, Webpack, etc.)
- β Supervisor integration for queue workers
- β Centralized Makefile for streamlined DX
βββ data/ # Volumes (mysql, pgsql, redis)
βββ docker/
β βββ nginx/
β β βββ nginx.conf
β β βββ sites-available/ # Contains available vhosts
β β βββ sites-enabled/ # Contains symlinks to enabled vhosts
β βββ php/
β β βββ entrypoint.sh
β β βββ [5.6 | 7.4 | 8.0 | 8.3]/ β Dockerfile + php.ini
β βββ supervisor/
β βββ supervisord.conf
βββ logs/ # Logs from services (e.g., nginx)
βββ src/ # Where your PHP projects live
βββ docker-compose.yml # Core services (nginx, php, node, redis)
βββ docker-compose.mysql.yml # Optional MySQL stack
βββ docker-compose.pgsql.yml # Optional PostgreSQL stack
βββ Makefile # Dev command runner
cp -r this-folder my-new-project
cd my-new-project
cp .env.example .envPHP_VERSION=8.3DB_CONNECTION=mysql# or pgsqlmake enable-site site=api.local.conf127.0.0.1 api.local
127.0.0.1 symfony.local
make up-db # Auto-detects DB from .env| Command | Description |
|---|---|
| make up | Start default stack (nginx, php, redis) |
| make up-mysql | Start stack with MySQL |
| make up-pgsql | Start stack with PostgreSQL |
| make up-db | Detects DB from .env and runs accordingly |
| make down | Stop and remove containers |
| make restart | Restart stack |
| make switch-php version=8.2 | Change PHP version |
| make logs | Tail container logs |
| make bash | Open shell in PHP container |
| make composer-create-project project=... name=... | Run composer install |
| make composer-install project=... | Run composer install |
| make composer-update project=... | Run composer update |
| make composer-require project=... package=... | Install package via Composer |
| make run-php-command project=... command=... | Run any PHP CLI command |
| make run-npm-command project=... command=... | Run any npm command (install, run dev, etc.) |
| make enable-site site=... | Enable virtual host |
| make new-site site=... | Create + enable new virtual host |
This development environment is designed for Linux/macOS or Windows with WSL2.
To use this setup on Windows, follow these steps:
- Install WSL2 (Windows Subsystem for Linux)
- Install a Linux distribution (Ubuntu is recommended)
- Ensure Docker Desktop is installed and configured to use WSL2
- Open a WSL terminal and use
makecommands as usual:
make up-db
make switch-php version=8.2
make run-php-command command="artisan migrate"If you can't use WSL2, you may run equivalent commands manually from Git Bash or CMD (limited support):
docker compose -f docker-compose.yml -f docker-compose.mysql.yml up -d --build
docker exec -it php_project_php bash
composer installβ οΈ Note: Some Makefile logic (like sed, ln -sf, conditional execution) won't work on Windows without WSL2.
For full compatibility, WSL2 is strongly recommended.
| Version | Composer | Xdebug | Notes |
|---|---|---|---|
| 5.6 | β | β | Legacy, limited |
| 7.4 | β | β | Stable, supported |
| 8.0+ | β | β | Recommended for new projects |
- Node is available for projects using modern frontend tooling (Vite, Webpack, etc.)
- Supervisor is integrated and can be configured via
.envto run queue workers. - Redis is included and exposed for local debugging and pub/sub dev scenarios.
- Ports for Node (e.g., Vite) are optional and can be configured dynamically.