Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1001 Bytes

File metadata and controls

33 lines (25 loc) · 1001 Bytes

docker-image-php-cli

A Docker image for running PHP CLI tooling (Composer, PHPUnit, PHPStan, PHPCS, PHPBench, ...) against a project, without installing PHP locally.

The image expects the project to be mounted at /app. It has no entrypoint, so any command can be run directly.

Usage

services:
  cli:
    image: ghcr.io/phppdf/docker-image-php-cli:dev
    volumes:
      - ./:/app
docker compose run --rm cli composer install
docker compose run --rm cli vendor/bin/phpunit

By default the image runs as a non-root user, app (UID/GID 1000), so files created inside the container are owned by your user on the host (on most single-user Linux installations, the first user is UID/GID 1000). If your UID/GID differs, override it with docker compose run --rm --user "$(id -u):$(id -g)" cli ....

Run PHPUnit with coverage (the image includes Xdebug):

docker compose run --rm -e XDEBUG_MODE=coverage cli vendor/bin/phpunit --coverage-html .phpunit-coverage