What is setup-php?
setup-php is a GitHub Action that provides a cross-platform interface to configure PHP environments in your CI/CD workflows. It supports Ubuntu, Windows, and macOS on both GitHub-hosted and self-hosted runners, and handles the differences between platforms automatically.
With a single step in your workflow, you can:
- Install a specific PHP version (5.3 through 8.6, including nightly builds)
- Add PHP extensions from packages, PECL, or git repositories
- Configure
php.inivalues - Set up code coverage drivers (Xdebug or PCOV)
- Install popular tools like Composer, PHPUnit, PHPStan, and 50+ more
OS/Platform support
Both GitHub-hosted and self-hosted runners are supported on the following operating systems.GitHub-hosted runners
Self-hosted runners
If the requested PHP version is pre-installed on the runner,
setup-php switches to it. Otherwise it installs the requested version. Operating systems based on the supported Ubuntu and Debian versions are also supported on a best-effort basis.PHP version support
setup-php supports PHP 5.3 through 8.6 across all supported platforms, with some variation by runner type.
- GitHub-hosted runners (non-ARM): PHP 5.3 to PHP 8.6
- GitHub-hosted macOS ARM64 (
macos-14): PHP 5.6 to PHP 8.6 - Self-hosted runners: PHP 5.6 to PHP 8.6
Specifying
8.6 in the php-version input installs a nightly build of PHP 8.6.0-dev from the master branch of PHP. These builds may contain bugs and breaking changes.Explore setup-php
Quickstart
Get PHP configured in your GitHub Actions workflow in minutes with a complete working example.
Configuration
Full reference for all inputs, outputs, and environment flags.
Extensions
Install PHP extensions from packages, PECL, or git repositories.
Tools
Set up 50+ PHP tools globally, including PHPUnit, PHPStan, and Composer.