Skip to main content

Docker for small dev setups

· One min read
Daniel Ruf

Old PHP projects often still use Composer 1 and require an old PHP version to run. To make life easier for the other developers, I have created some efficient and small development setups based on Docker.

The commands used are normally a bit longer and hard to remember. So we use a bin folder and place our bash scripts there. In these bash scripts, we run specific Docker images. This prevents that we clutter our local setups with many different old PHP versions, which also often leads to conflicts.

The following one-liner scripts are used in our old Symfony projects, which still use PHP 7.1 and Composer 1.

bin/composer (uses Composer 1)

#!/usr/bin/env bash

docker run --rm --interactive --tty --volume "$PWD":/app composer:1 "$@"

bin/dev-php (uses the built-in web server of PHP 7.1)

#!/usr/bin/env bash

docker run -it --rm -v "$PWD":/usr/src/app -p -w /usr/src/app php:7.1-cli php -S -t public

bin/dev (uses the Symfony dev server on PHP 7.1)

#!/usr/bin/env bash

docker run -it --rm -v "$PWD":/usr/src/app -p -w /usr/src/app php:7.1-cli php bin/console server:run --env dev