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/Package | Runs on | Workflow |
---|---|---|
Blackfire | macOS , ubuntu and windows | blackfire.yml |
Blackfire Player | macOS , ubuntu and windows | blackfire-player.yml |
CakePHP with MySQL and Redis | ubuntu | cakephp-mysql.yml |
CakePHP with PostgreSQL and Redis | ubuntu | cakephp-postgres.yml |
CakePHP without services | macOS , ubuntu and windows | cakephp.yml |
CodeIgniter | macOS , ubuntu and windows | codeigniter.yml |
Laravel with MySQL and Redis | ubuntu | laravel-mysql.yml |
Laravel with PostgreSQL and Redis | ubuntu | laravel-postgres.yml |
Laravel without services | macOS , ubuntu and windows | laravel.yml |
Lumen with MySQL and Redis | ubuntu | lumen-mysql.yml |
Lumen with PostgreSQL and Redis | ubuntu | lumen-postgres.yml |
Lumen without services | macOS , ubuntu and windows | lumen.yml |
Phalcon with MySQL | ubuntu | phalcon-mysql.yml |
Phalcon with PostgreSQL | ubuntu | phalcon-postgres.yml |
Roots/bedrock | ubuntu | bedrock.yml |
Roots/sage | ubuntu | sage.yml |
Slim Framework | macOS , ubuntu and windows | slim-framework.yml |
Symfony with MySQL | ubuntu | symfony-mysql.yml |
Symfony with PostgreSQL | ubuntu | symfony-postgres.yml |
Symfony without services | macOS , ubuntu and windows | symfony.yml |
Yii2 Starter Kit with MySQL | ubuntu | yii2-mysql.yml |
Yii2 Starter Kit with PostgreSQL | ubuntu | yii2-postgres.yml |
Zend Framework | macOS , ubuntu and windows | zend-framework.yml |
PHP Setup Action is released under an MIT license. More information at https://github.com/shivammathur/setup-php