PHP-DEV is a small package that includes a web server, PHP and some tools needed to develop a web application. You can easily decide which version of PHP you want to use and whether you want to start an Apache or a Nginx webserver by setting the values in a docker-compose.yml. We recommend using pluswerk/docker-global as a wrapper for your projects, since this Dockerfile has been built keeping that in mind.
- php versions supported:
7.1
-8.3
- webserver supported:
nginx
andapache
- alpine images:
-alpine
- examples
ghcr.io/pluswerk/php-dev:nginx-8.3-alpine
ghcr.io/pluswerk/php-dev:apache-7.1-alpine
ghcr.io/pluswerk/php-dev:nginx-8.0
- list of all Tags
Create a compose/Development/docker-compose.yml
like shown below.
Change all your settings. Mainly the VIRTUAL_HOST
, WEB_DOCUMENT_ROOT
and optionally the Application Context.
The Environment Variable CONTEXT
is used to switch between different docker-compose.yml files.
Then you can copy the start.sh into your project and start it.
The base Docker Images are webdevops/php-apache-dev and webdevops/php-nginx-dev respectively. (github)
- XDebug - how to debug your code
- Environment Variables - what can I configure
- PHP Profiling - why is my code so slow/memory hungry
- Code Coverage - I want to test my code with code coverage (phpunit, infection)
- Change docker project name - all my projects are in folders named the same
- Nginx Reverse Proxy - VIRTUAL_HOST explanation
- TYPO3 configuration >=8 - AdditionalConfiguration.php
- TYPO3 configuration <=7 - AdditionalConfiguration.php
- ImageMagick or GraphicMagick - using php module
This is an example of a docker-compose.yml file. It is enough to put this file into the project, configure it and start the Docker Project. Further information can be found in the Documentation.
Example file: compose/Development/docker-compose.yml
services:
web:
image: ghcr.io/pluswerk/php-dev:nginx-8.3-alpine
volumes:
- .:/app
# the docker socket is optional if no node container is needed
- /var/run/docker.sock:/var/run/docker.sock:ro
- ~/.ssh:/home/application/.ssh
- ~/.composer/cache:/home/application/.composer/cache
- ~/.gitconfig:/home/application/.gitconfig
environment:
# Take a look at VIRTUAL_* in the documentation under Nginx Reverse Proxy
- VIRTUAL_HOST=docker-website.${TLD_DOMAIN:?TLD_DOMAIN is required},sub.docker-website.${TLD_DOMAIN:?TLD_DOMAIN is required}
# - HTTPS_METHOD=noredirect
- WEB_DOCUMENT_ROOT=/app/public
- XDEBUG_CLIENT_HOST=${XDEBUG_CLIENT_HOST:-}
- php.xdebug.idekey=${XDEBUG_IDEKEY:-PHPSTORM}
- PHP_IDE_CONFIG=${XDEBUG_IDEKEY:-"serverName=_"}
# Project Env vars (enable what you need)
# - APP_ENV=development_docker
# - PIMCORE_ENVIRONMENT=development_docker
# - TYPO3_CONTEXT=Development/docker
# Don't forget to connect via bash start.sh
- APPLICATION_UID=${APPLICATION_UID:-1000}
- APPLICATION_GID=${APPLICATION_GID:-1000}
node:
image: node:18
volumes:
- ./:/app
working_dir: /app
environment:
# Don't forget to connect via bash start.sh
- APPLICATION_UID=${APPLICATION_UID:-1000}
- APPLICATION_GID=${APPLICATION_GID:-1000}
stop_signal: SIGKILL
entrypoint: bash -c 'groupmod -g $$APPLICATION_GID node; usermod -u $$APPLICATION_UID node; tail -f /dev/null'
networks:
default:
name: global
external: true
Hint for the example above: In your own configuration you might want to replace docker-website with your project name, e.g typo3. TLD_DOMAIN is an environment variable, your nginx container listens on for incoming requests. e.g. example.com. Your project will then be reachable by going to this domain: typo3.example.com
This project is a basic php-installation and should be able to run most applications. Nonetheless has this tool successfully been tested/used with:
- TYPO3 >=7
- PIMCore >= 5.4
- Standalone PHP (Symfony, Laravel/Lumen, Vanilla) Projects
- WordPress >= 4.5
If you find any bug, don't hesitate to file an issue and/or pull request.