Skip to main content

Quick Start

Get PHP set up in your GitHub Actions workflow in minutes.

PHP Versions

Support for PHP 5.3 through 8.6 including nightly builds.

Extensions

Install PHP extensions from PECL, packages, or git repositories.

Tools

Set up 50+ PHP tools globally including PHPUnit, PHPStan, and Composer.

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 — both GitHub-hosted and self-hosted runners.
- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.4'
    extensions: mbstring, intl, pdo_mysql
    ini-values: post_max_size=256M, max_execution_time=180
    coverage: xdebug
    tools: composer, phpunit

Key capabilities

Cross-platform

Works on Ubuntu, Windows, and macOS runners. Handles differences automatically.

PHP 5.3 to 8.6

Set up any PHP version from 5.3 to the latest nightly build of 8.6.

Extension management

Add, remove, or disable PHP extensions. Supports PECL, packages, and source builds.

Coverage drivers

Configure Xdebug or PCOV for code coverage, or disable coverage to speed up tests.

50+ tools

Install PHPUnit, PHPStan, Psalm, php-cs-fixer, Rector, and many more globally.

Composer integration

Authenticates with GitHub, Private Packagist, and custom package registries.

Platform support

PlatformGitHub-hostedSelf-hosted
Ubuntu 22.04 / 24.04
Windows Server 2022 / 2025
macOS 14 / 15 / 26
Debian 11 / 12 / 13

Get started

1

Add the action to your workflow

Add shivammathur/setup-php@v2 to your .github/workflows/*.yml file.
2

Choose your PHP version

Set php-version to any version from 5.3 to 8.6, or use latest for the newest stable release.
3

Add extensions and tools

Use the extensions and tools inputs to install what your project needs.
4

Run your tests

Your PHP environment is ready — run PHPUnit, static analysis, or any other CI steps.

See the quickstart guide

A complete working workflow example to get you started in under 5 minutes.

Build docs developers (and LLMs) love