Today I came across a really useful set of tools. Magento 2 github actions:


Which means you can run a github action workflows to scan your code for Magento coding standard. For example:



name: ExtDN Static Tests
on: [push]

    name: Static Code Analysis
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - uses: extdn/github-actions-m2/magento-coding-standard@master

Pretty amazing. However I would also like a github action to scan Magento 2 extension using PHPCompatibility standard for a defined set of php versions.

For example locally the command would look a bit like this

vendor/squizlabs/php_codesniffer/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 7.0-7.4 --colors --warning-severity=0 --report=full,summary --extensions=php,phtml ./

I've had a few goes but I can't get the syntax right.

Has someone somewhere got a github action which does the above?


4 Answers 4


Late answer ...

I've played around with github actions and PHPCompatibility check these days.

If you use composer for you project, you dont need a docker image.

Add (dev) dependencies:
  • squizlabs/php_codesniffer
  • phpcompatibility/php-compatibility
(Auto-)Install PHPCompatibility (and other) rules
  • dealerdirect/phpcodesniffer-composer-installer
Add Workflow file to .github/workflows with ...
      - name: Checkout code
        uses: actions/checkout@v3

      - name: PHPCodeSniffer
        run: php vendor/bin/phpcs <your-options>

E.g. ...

  • I finally remembered how it all works. I posted another answer. Nov 29, 2022 at 14:19
  • Also I think the reason I didn't go this route is that you have to remember to exclude scanning vendor folder Nov 29, 2022 at 14:21

The follow up to this is that I got a couple of merge requests accepted and it can be achieved with following github action

name: ExtDN PHP Compatibility
on: [push, pull_request]

    name: ExtDN PHP Compatibility
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - uses: extdn/github-actions-m2/php-compatibility/8.1@master

Can toggle version to match PHP version you are working with


The default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file against the PEAR coding standard, simply specify the file's location:

$ phpcs /path/to/code/myfile.php

Or if you wish to check an entire directory you can specify the directory location instead of a file.

$ phpcs /path/to/code-directory

If you wish to check your code against the PSR-12 coding standard, use the --standard command-line argument:

$ phpcs --standard=PSR12 /path/to/code-directory

If PHP_CodeSniffer finds any coding standard errors, a report will be shown after running the command.

Full usage information and example reports are available on the usage page

  • Thanks for your answer. Please check again. I'm looking for a github action that checks code against the PHPCompatibility standard. Jan 13, 2022 at 10:55

I submitted a pull request to add the functionality


Just waiting on someone their side to build docker image so I can start to use it in github actions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.