DEV Community

Cover image for Github Action for PHP packages

Github Action for PHP packages

shivammathur profile image Shivam Mathur Updated on ・1 min read

GitHub recently launched GitHub Actions which allows applications to do CI/CD in GitHub itself based on a workflow defined in a yml file which lives alongside the code in .github/workflows much like if you used Travis CI, you would have a .travis.yml file.

Anyone looking to test PHP packages can just use the setup-php action, run the tests and do CI/CD. The action sets up PHP, along with required extensions, tools and configuration. The setup-php action works on all virtual environments viz. linux, macOS and windows supported by GitHub actions. For more info check the PHP Action

GitHub logo shivammathur / setup-php

GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer...

Here is an example of how you can use it

name: Test
on: [push]
        operating-system: [ubuntu-latest, windows-latest, macos-latest]
        php-versions: ['7.2', '7.3', '7.4']
    runs-on: ${{ matrix.operating-system }}
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
          php-version: ${{ matrix.php-versions }}
          extensions: mbstring, intl
          ini-values: post_max_size=256M, log_errors=1
          coverage: pcov
          tools: pecl
      .... Add more steps to install dependencies and then test

Enter fullscreen mode Exit fullscreen mode


Editor guide