This repository is a docker image based on official php, composer and alpine docker images to help you to build and test your PHP projects with different PHP version.
This docker image contains a necessary tools you need to analyze and test your PHP project
- xdebug
- phpunit
- rector
- phpstan
- psalm
- phpcs
- php-cs-fixer
- phpmd
- phpcpd (available from php 7.3 version)
Below is the list of docker images available by PHP versions:
PHP version | Docker image tags |
---|---|
PHP 8.4 | Coming soon (Waiting for xdebug 3.4) |
PHP 8.3 | ghcr.io/devgine/composer-php:latest |
PHP 8.2 | ghcr.io/devgine/composer-php:v2-php8.2-alpine |
PHP 8.1 | ghcr.io/devgine/composer-php:v2-php8.1-alpine |
PHP 8.0 | ghcr.io/devgine/composer-php:v2-php8.0-alpine |
PHP 7.4 | ghcr.io/devgine/composer-php:v2-php7.4-alpine |
PHP 7.3 | ghcr.io/devgine/composer-php:v2-php7.3-alpine |
PHP 7.2 | ghcr.io/devgine/composer-php:v2-php7.2-alpine |
docker run -ti -v LOCAL_PROJECT_DIR:/var/www/composer ghcr.io/devgine/composer-php:latest sh
FROM ghcr.io/devgine/composer-php:latest
# Add your custom instructions here
# example: install bash
RUN apk add --no-cache bash
# example: expose 8080 port
EXPOSE 8080
#...
Inside the container, you can run any tool you need from any working directory.
Global vendor binaries are added to the PATH environment.
composer --help
simple-phpunit --help
rector --help
phpstan --help
psalm --help
phpcs --help
php-cs-fixer --help
phpmd --help
phpcpd --help
name: 'Workflow name'
on:
push
jobs:
job-id:
runs-on: ubuntu-latest
...
container:
image: ghcr.io/devgine/composer-php:latest
steps:
- name: 'Run Tests'
run: simple-phpunit --coverage text
...
An example with matrix strategy
name: 'Matrix strategy'
on:
push
jobs:
job-id:
runs-on: ubuntu-latest
...
strategy:
fail-fast: false
matrix:
tag: ['v2-php8.3-alpine', 'v2-php8.2-alpine', 'v2-php8.1-alpine', 'v2-php8.0-alpine', 'v2-php7.4-alpine']
container:
image: ghcr.io/devgine/composer-php:${{ matrix.tag }}
steps:
- name: 'Run Tests'
run: simple-phpunit --coverage text
...
tests:
image: ghcr.io/devgine/composer-php:latest
...
script:
- simple-phpunit --coverage text
An example with matrix strategy
tests:
parallel:
matrix:
TAG: ['v2-php8.3-alpine', 'v2-php8.2-alpine', 'v2-php8.1-alpine', 'v2-php8.0-alpine', 'v2-php7.4-alpine']
image: ghcr.io/devgine/composer-php:${TAG}
...
script:
- simple-phpunit --coverage text