Shared composite action that prepares PHP, extensions, optional PHP tools, and Composer for workflow jobs. Reads the required PHP version and extensions from composer.json, installs the matching PHP runtime, optionally installs global tools through shivammathur/setup-php, and runs composer install.
Every PHP-based action in this repository (run-phpstan, run-pint, run-phpinsights, run-phpmd, run-filacheck, run-phptests, check-security-composer) includes this action as its first step, so PHP is always ready without an explicit step in your workflow. The actual PHP/Composer install runs once per job: once it has run — whether triggered by an explicit setup-php step or by one of the actions above — later invocations in the same job detect the TOMGRV_PHP_SETUP environment marker and skip straight through. Add an explicit setup-php step yourself only when you need to pass custom options or tools.
This action also puts vendor/bin (project-local) and the global Composer bin directory (composer config -g home) on PATH, once per job. Every action that embeds setup-php can therefore call its tool (pest, phpunit, pint, phpstan, phpmd, phpinsights, filacheck, dep, ...) by bare name instead of resolving the path itself.
Optional. Additional options to pass to composer install, such as --no-dev. Defaults to none.
Optional. Coverage driver passed to shivammathur/setup-php: xdebug, pcov or none. Defaults to xdebug. Validation-only callers (such as check-lock) pass none to skip loading xdebug. Like the rest of the PHP setup it is applied by the first caller in a job.
Optional. Comma-separated tools to install with shivammathur/setup-php, such as reviewdog,phpstan,phpmd. Defaults to none.
Optional. Comma-separated Composer packages to install globally (composer global require), each optionally pinned to a version with package:constraint (e.g. deployer/deployer:^7). Runs after composer install, on every invocation of this action within a job, even when the PHP/Composer setup itself was skipped as an already-ran duplicate, since a different caller may need a different global package. A package already present in the project's own vendor/ (via composer.json), or already installed globally, is skipped. Defaults to none.
Optional. If true, skips the composer install step. Useful for actions that only need PHP and Composer available, but not the project's dependencies. Defaults to false.
php-version: Detected PHP version fromcomposer.json, or the default (8.3).php-extensions: Detected PHP extensions fromcomposer.json, or empty.
- check-lock — validate
composer.json/composer.lock; run this action first ifcomposerneeds to be onPATH. - check-security-composer — audit Composer dependencies; already included automatically.
- run-phpinsights — run PHP Insights; already included automatically.
- run-filacheck — run FilaCheck; already included automatically.
- run-phpmd — run PHPMD; already included automatically.
- run-phpstan — run PHPStan; already included automatically.
- run-pint — run Pint; already included automatically.
- run-phptests — run the test suite; already included automatically.
- list-packages — discover Composer packages after setup.
Run this action locally from a clone of this repository with zz-use:
zz-use -x ./setup-phpRequired environment variables must be set before running. See Inputs for details.
name: PR PHP Checks
on:
pull_request:
jobs:
php-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP toolchain
uses: tomgrv/actions/setup-php@v5
with:
tools: reviewdog,phpstan,phpmd,phpinsights,pint
- name: Validate composer
uses: tomgrv/actions/check-lock@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Audit Composer dependencies
uses: tomgrv/actions/check-security-composer@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run PHPStan
uses: tomgrv/actions/run-phpstan@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
uses: tomgrv/actions/run-phptests@v5