Skip to content

Docker image based on official alpine image, PHP-fpm and composer. This image will help you to build and test your PHP projects with different PHP version. It contains a necessary tools you need to analyse and test your PHP project (xdebug, phpunit, phpstan, psalm, phpcs, php-cs-fixer, phpmd, phpcpd and rector).

License

Notifications You must be signed in to change notification settings

devgine/composer-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Composer PHP docker image

Build License GitHub top language Packages retention policy

cover.png

About

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

Usage

Install from the command line

docker run -ti -v LOCAL_PROJECT_DIR:/var/www/composer ghcr.io/devgine/composer-php:latest sh

All versions

Use as base image in Dockerfile

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
#...

Use components

Inside the container, you can run any tool you need from any working directory.
Global vendor binaries are added to the PATH environment.

Composer

composer --help

PHP Unit

simple-phpunit --help

Rector

rector --help

PHPStan

phpstan --help

Psalm

psalm --help

PHP Code sniffer

phpcs --help

PHP Coding Standards Fixer

php-cs-fixer --help

PHP Mess Detector

phpmd --help

PHP Copy Past Detector

phpcpd --help

Use image in continuous integration

GitHub action

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
      ...

Gitlab CI

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

References

About

Docker image based on official alpine image, PHP-fpm and composer. This image will help you to build and test your PHP projects with different PHP version. It contains a necessary tools you need to analyse and test your PHP project (xdebug, phpunit, phpstan, psalm, phpcs, php-cs-fixer, phpmd, phpcpd and rector).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages