This repository allows you to quickly get a development environment up and running using Docker, including a MySQL database and some debugging tools.
This environment includes the latest versions of the following software:
nginx:alpine
php:8.0-fpm
mysql:latest
xdebug
- Docker (https://www.docker.com/products/docker-desktop)
- Tested on macOS 10.15 (Catalina) and Windows 10 Version 10.0.18362
- Windows 10 requires Docker File Sharing with the C drive to be enabled in the Docker settings, restart may be required after enabling sharing
- Using composer:
composer create-project jlucki/docker-php-dev-env <project name>
or download the files from this repo and copy them to your project directory - Run
docker-compose up
from the project directory - Visit
localhost
in your browser
The following instructions are for PHPStorm.
- Click on Run > Edit Configurations
- Click the
+
and add a new PHP Remote Debug configuration - Give the configuration a name
- Tick Filter debug connection by IDE key
- Add
PHPSTORM
in the session id - Click the
...
next to Server - Click the
+
to add a new server - Give the server a name, and set the host to
127.0.0.1
- Tick Use path mappings
- Open the Project files drop down
- Find the public folder, and under Absolute path on the server add
/code/public
- Hit Apply and OK until you've returned to the IDE
- Click the Start Listening for PHP Debug Connections icon
- Set a breakpoint in your code
- Refresh the page in your browser
- Accept Incoming Connection From Xdebug
- Happy debugging!
See https://xdebug.org/docs/remote for how to enable xdebug sessions.
For database connections, use mysql
as the hostname. If you would like a different hostname, change the service name in the docker-compose.yml
file.