Prerequisites
Before you begin, you need:- A GitHub repository with GitHub Actions enabled
- A
.github/workflows/directory (or the ability to create one) - Basic familiarity with GitHub Actions workflow syntax
Set up PHP in your workflow
Create a workflow file
Create a file at
.github/workflows/ci.yml in your repository. This file defines the workflow that GitHub Actions will run..github/workflows/ci.yml
Add the setup-php step
Add
shivammathur/setup-php@v2 as a step in your job. Specify the PHP version you need with the php-version input..github/workflows/ci.yml
Add extensions
Use the Extensions are sourced from packages (on Ubuntu), PECL, or git repositories depending on your platform. Prefix an extension with
extensions input to install PHP extensions. It accepts a comma-separated list of extension names.: to disable it instead of installing it.Add tools
Use the You can also install a specific version of any tool by appending
tools input to install PHP tools globally. It accepts a comma-separated list of tool names. The latest stable version of composer is always set up by default.:version, for example phpunit:11.Complete workflow examples
The following examples show complete, working workflow files you can use as a starting point.The
basic.yml example uses coverage: xdebug. If you are not generating coverage reports, use coverage: none instead — this improves PHP performance because Xdebug is disabled.Next steps
Configuration reference
See all available inputs, outputs, and environment flags for setup-php.
Extensions
Learn how to install, version-pin, and disable PHP extensions.
Tools
Browse the full list of 50+ supported PHP tools.
Coverage
Configure Xdebug, PCOV, or disable coverage drivers.