A ready-to-use PHP development environment with Docker, featuring PhpStorm integration and xDebug debugging support.
- Docker Desktop installed and running
- PhpStorm (optional, for debugging)
git clone [email protected]:jstormes/php-docker-quickstart.git
cd php-docker-quickstart
docker-compose up -d
docker-compose exec php-dev composer install- Development server: http://localhost:8088
- Production like server: http://localhost:9088
- PhpMyAdmin: http://localhost:7088
- Command Line: docker-compose exec php-dev bash
php-docker-quickstart/
βββ app/ # Your PHP application code
β βββ public/ # Web root directory
βββ config/ # Configuration files
β βββ docker/ # Docker configuration files
β βββ php.ini-development # Development PHP configuration
β βββ php.ini-production # Production PHP configuration
β βββ xdebug_3.x.x.ini # xDebug development settings
βββ database/ # Database initialization scripts
β βββ 0_README.md # Database setup documentation
β βββ 001_StartupTables.sql # Initial database schema
βββ xdebug.info/ # xDebug profiling output directory
βββ docker-compose.yml # Main Docker configuration
βββ Dockerfile # Docker image definition
βββ README.md # This file
βββ SETUP.md # Detailed setup guide
βββ QUICK_REFERENCE.md # Quick reference guide
- PHP 8.x with common extensions
- MariaDB database server
- PhpMyAdmin for database management
- Hot reload - code changes reflect immediately for Development server
- Host: localhost
- Port: 5000
- Username: root
- Password: password
- Database: app
- Initialization: Files in
database/directory
- Chrome: xDebug Helper
- Firefox: xDebug Helper
- Edge: xDebug Helper
- Set IDE key to:
PHPSTORM - Set Trace Trigger to:
XDEBUG_TRACE - Set Profile Trigger to:
XDEBUG_PROFILE
- Open Settings (
Ctrl+Alt+S) - Go to Build, Execution, Deployment β Docker
- Add Docker server with name:
Docker
- Click the bug icon in PhpStorm to start listening
- Press
Ctrl+Shift+Xin browser and select "debug" - Set breakpoints in your PHP code
- Refresh the page to trigger debugging
docker-compose -f docker-compose.yml up php-prod --build- Edit
docker-compose.ymland update the image name:image: your-dockerid/yourimage
- Push the image:
docker compose push php-prod
To use private repositories inside the container:
- Uncomment the
secretssection indocker-compose.yml - Ensure your SSH keys are in
~/.ssh/on your host machine - Test connection:
docker-compose exec php-dev bash ssh [email protected]
To use AWS services inside the container:
- Uncomment the AWS secrets in
docker-compose.yml - Ensure your AWS credentials are in
~/.aws/on your host machine - Uncomment "Install AWS-CLI" in the Dockerfile
- Test connection:
docker-compose exec php-dev bash aws sts get-caller-identity
This environment includes Claude Code CLI for AI-powered development assistance:
- Uncomment the Claude secrets section in
docker-compose.yml:secrets: claude-auth: file: ~/.claude/.credentials.json claude-cfg: file: ~/.claude.json
- Uncomment the Claude secrets mapping in the php-dev service
- (Optional) Set your Anthropic API key as an environment variable:
export ANTHROPIC_API_KEY=your_api_key_here - Access Claude Code inside the development container:
docker-compose exec php-dev bash claude - Claude Code can help with:
- Code generation and refactoring
- Debugging assistance
- Code review and optimization
- Documentation generation
- Test writing and execution
This environment includes Gemini CLI for AI-powered development assistance:
- Uncomment the Gemini secrets section in
docker-compose.yml:secrets: gemini-auth: file: ~/.gemini
- Uncomment the Gemini secrets mapping in the php-dev service
secrets: - source: gemini-auth target: /home/user/.gemini.system
- Access Gemini inside the development container:
docker-compose exec php-dev bash gemini
# Start development environment
docker-compose up -d
# Stop all services
docker-compose down
# View logs
docker-compose logs php-dev
# Access container shell
docker-compose exec php-dev bash
# Rebuild containers
docker-compose up --buildIf you get port conflicts, edit the ports in docker-compose.yml:
ports:
- "8089:80" # Change 8088 to another port- Ensure xDebug Helper extension is installed and configured
- Check that PhpStorm is listening for connections
- Verify the IDE key matches in both PhpStorm and browser extension
- Ensure MariaDB container is running:
docker-compose ps - Check database logs:
docker-compose logs mariadb - Verify connection string in environment variables
- Docker Documentation
- xDebug Documentation
- PhpStorm Docker Integration
- Production Hosting Options
- Database Setup Guide
This project is a template. Feel free to fork and customize for your own projects.
Video Tutorial: PHP Docker Quickstart Setup