Composer authentication
GitHub Composer authentication
By default,setup-php uses the GITHUB_TOKEN secret automatically provided by GitHub Actions to authenticate Composer requests to GitHub package sources. To use a Personal Access Token (PAT) instead, pass it via the github-token input:
The
COMPOSER_TOKEN and GITHUB_TOKEN environment variables have been deprecated in favour of the github-token input and will be removed in the next major version.GitHub Enterprise
For GitHub Enterprise users,github-token does not default to GITHUB_TOKEN. Use a PAT explicitly:
Private Packagist authentication
If your project uses Private Packagist for private Composer dependencies, set thePACKAGIST_TOKEN environment variable:
Manual Composer authentication
For private repositories hosted outside GitHub or Private Packagist, setCOMPOSER_AUTH_JSON with the authentication credentials in JSON format. The structure follows the Composer authentication documentation.
Inline PHP scripts
You can run PHP code directly in a workflow step without saving it to a file. Setshell: php {0} on the step and write your PHP code in the run block:
Force update setup
Pre-installed PHP versions are not updated to their latest patch release by default. Set theupdate environment variable to true to force an update to the latest patch version:
Verbose debugging
When troubleshooting a workflow, switch from thev2 tag to the verbose tag. The verbose tag outputs all setup logs and is kept in sync with the latest releases:
v2 once your issue is resolved to keep your workflow logs clean.
Debug builds
Production PHP builds do not include debugging symbols by default. Set thedebug environment variable to true to install a build with debugging symbols (supported on PHP 5.6 and above):
Linux
Linux
Debug symbols are added as debug info files in the
/usr/lib/debug/.build-id directory. These files match the build-id in the ELF section of the PHP binaries, and tools like gdb resolve symbols automatically.Windows
Windows
Debug symbols are added as
.pdb files in the PHP installation directory.macOS
macOS
Debug symbols are compiled directly into the binaries.
JIT configuration
Just-in-time compilation is available on PHP 8.0 and above. To enable it:Enable opcache in CLI mode
JIT requires opcache to be active on the CLI. Add
opcache.enable_cli=1 to your ini-values.Disable coverage drivers
JIT conflicts with Xdebug, PCOV, and any extension that overrides
zend_execute_ex. Set coverage: none and disable any such extensions.JIT mode reference
| Value | Mode |
|---|---|
disable | JIT disabled |
off | JIT compiled but not used |
on | Alias for tracing |
tracing | Trace-based JIT (recommended for most workloads) |
function | Function-level JIT |
1235 | Default numeric mode (tracing with optimizations) |
Versioning best practices
Use the v2 rolling tag
Use the v2 rolling tag
The
v2 tag is a rolling tag kept in sync with the latest minor and patch releases. Using it means you automatically receive bug fixes, security patches, new PHP version support, and new features without updating your workflow file.Use Dependabot to track semantic versions
Use Dependabot to track semantic versions
If you prefer pinned semantic release versions (for example,
v2.33.0) over the rolling v2 tag, enable Dependabot for GitHub Actions to receive automated PRs whenever a new version is released.Avoid commit SHAs unless you have automated tooling
Avoid commit SHAs unless you have automated tooling
Pinning to a commit SHA provides the strongest supply-chain guarantee, but SHA pins go stale silently. Only use commit SHAs if you have tooling in place to update them with each release.
Never use the main branch
Never use the main branch
Do not reference the
main branch as your version. The main branch may contain in-progress breaking changes and does not guarantee a stable API.Migrating from v1
Migrating from v1
The
v1 tag is no longer supported. If your workflow still references setup-php@v1 or a 1.x.y version, follow the switch to v2 guide to migrate.