Github Action is one of the new great features in Github that will give you power to automate your workflow, connect with the tools you know and love; have more freedom to innovate and be creative; deploy to any cloud, build containers, automate messages, and lots more. One of these actions is contributed by Shivam Mathur, PHP developer from India, will help you with all your PHP applications.

Setup PHP Action

So SetupPHP is a GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer. This action gives you a cross platform interface to setup the PHP environment you need to test your application. You can setup PHP from version 5.3 to 8.0 ! Github hosted runners however are available only for PHP 7.4 and Ubuntu 20.04, Windows Server 2019 and macOS Catalina 10.15.

For example to setup a particular version of PHP :

steps:
- name: Checkout
  uses: actions/checkout@v2

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '7.4'
    extensions: mbstring, intl
    ini-values: post_max_size=256M, short_open_tag=On
    coverage: xdebug    
    tools: php-cs-fixer, phpunit

You can also setup PHP on multiple Operating systems :

jobs:
  run:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: [ubuntu-latest, windows-latest, macos-latest]
        php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
    name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        extensions: mbstring, intl
        ini-values: post_max_size=256M, short_open_tag=On
        coverage: xdebug        
        tools: php-cs-fixer, phpunit

Coverage Integration

The tool allow not only to install PHP, but provides also configuration options for your environment and coverage integration. You can use one of the drivers available : Xdebug or PCOV only.

Additonal tools

Many additional tools are also available such as PHPUnit, PHPStan, Psalm …etc, and there are even a list of actions for different PHP Framework that you can directly use :

Framework/PackageRuns onWorkflow
BlackfiremacOSubuntu and windowsblackfire.yml
Blackfire PlayermacOSubuntu and windowsblackfire-player.yml
CakePHP with MySQL and Redisubuntucakephp-mysql.yml
CakePHP with PostgreSQL and Redisubuntucakephp-postgres.yml
CakePHP without servicesmacOSubuntu and windowscakephp.yml
CodeIgnitermacOSubuntu and windowscodeigniter.yml
Laravel with MySQL and Redisubuntularavel-mysql.yml
Laravel with PostgreSQL and Redisubuntularavel-postgres.yml
Laravel without servicesmacOSubuntu and windowslaravel.yml
Lumen with MySQL and Redisubuntulumen-mysql.yml
Lumen with PostgreSQL and Redisubuntulumen-postgres.yml
Lumen without servicesmacOSubuntu and windowslumen.yml
Phalcon with MySQLubuntuphalcon-mysql.yml
Phalcon with PostgreSQLubuntuphalcon-postgres.yml
Roots/bedrockubuntubedrock.yml
Roots/sageubuntusage.yml
Slim FrameworkmacOSubuntu and windowsslim-framework.yml
Symfony with MySQLubuntusymfony-mysql.yml
Symfony with PostgreSQLubuntusymfony-postgres.yml
Symfony without servicesmacOSubuntu and windowssymfony.yml
Yii2 Starter Kit with MySQLubuntuyii2-mysql.yml
Yii2 Starter Kit with PostgreSQLubuntuyii2-postgres.yml
Zend FrameworkmacOSubuntu and windowszend-framework.yml

PHP Setup Action is released under an MIT license. More information at https://github.com/shivammathur/setup-php

LEAVE A REPLY

Please enter your comment!
Please enter your name here