PHP development with Docker the easy way

Stefan Pöltl
3 min readOct 4, 2019

UPDATE(2021–04): Switched to PHP 7.4 and XDEBUG version 3!

As a developer, I want my applications to be up and running locally without having too much trouble to setup and configure the development environment. With Docker and docker-compose it’s already much better than in the past with virtual machines utilized by Virtualbox or any other memory bleeding app. To have an easy setup for all possible PHP versions with debugging enabled, I found a really good Docker image from Webdevops including PHP with development configuration and a NGINX webserver.

What do I need to start coding with PHP?

Install Docker Desktop on your machine and place the following docker-compose.yml in the root of your PHP Project:

version: '3'
services:
php:
image: webdevops/php-nginx-dev:7.4
working_dir: /app
environment:
- WEB_DOCUMENT_ROOT=/app/public
- PHP_DISPLAY_ERRORS=1
- PHP_MEMORY_LIMIT=2048M
- PHP_MAX_EXECUTION_TIME=-1
- XDEBUG_MODE=debug
- XDEBUG_START_WITH_REQUEST=yes
- XDEBUG_CLIENT_PORT=9000
- XDEBUG_CLIENT_HOST=host.docker.internal
- XDEBUG_MAX_NESTING_LEVEL=1000
ports:
- "8080:80"
volumes:
- ./:/app:rw,cached

--

--