MCPcopy
hub / github.com/shivammathur/setup-php

github.com/shivammathur/setup-php @2.37.2 sqlite

repository ↗ · DeepWiki ↗ · release 2.37.2 ↗
82 symbols 170 edges 20 files 7 documented · 9%
README

Setup PHP in GitHub Actions

Setup PHP in GitHub Actions

GitHub Actions status Codecov Code Coverage LICENSE PHP Versions Supported

setup-php reddit setup-php twitter setup-php status

Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in GitHub Actions. This action gives you a cross-platform interface to set up the PHP environment you need to test your application. Refer to Usage section and examples to see how to use this.

Contents

:cloud: OS/Platform Support

Both GitHub-hosted and self-hosted runners are supported by setup-php on the following OS/Platforms.

GitHub-Hosted Runners

Virtual environment Arch YAML workflow label Pre-installed PHP
Ubuntu 24.04 x86_64 ubuntu-latest or ubuntu-24.04 PHP 8.3
Ubuntu 22.04 x86_64 ubuntu-22.04 PHP 8.1
Ubuntu 24.04 aarch64 ubuntu-24.04-arm PHP 8.3
Ubuntu 22.04 aarch64 ubuntu-22.04-arm PHP 8.1
Windows Server 2025 x64 windows-2025 PHP 8.5
Windows Server 2022 x64 windows-latest or windows-2022 PHP 8.5
macOS Tahoe 26.x arm64 macos-26 -
macOS Sequoia 15.x arm64 macos-latest or macos-15 -
macOS Sonoma 14.x arm64 macos-14 -
macOS Tahoe 26.x x86_64 macos-26-intel PHP 8.5
macOS Sequoia 15.x x86_64 macos-15-intel PHP 8.5

Self-Hosted Runners

Host OS/Virtual environment YAML workflow label
Ubuntu 24.04 self-hosted or Linux
Ubuntu 22.04 self-hosted or Linux
Debian 13 self-hosted or Linux
Debian 12 self-hosted or Linux
Debian 11 self-hosted or Linux
Windows 7 and newer self-hosted or Windows
Windows Server 2012 R2 and newer self-hosted or Windows
macOS Tahoe 26.x x86_64/arm64 self-hosted or macOS
macOS Sequoia 15.x x86_64/arm64 self-hosted or macOS
macOS Sonoma 14.x x86_64/arm64 self-hosted or macOS
  • Refer to the self-hosted setup to use the action on self-hosted runners.
  • Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis.
  • If the requested PHP version is pre-installed, setup-php switches to it, otherwise it installs the PHP version.

:tada: PHP Support

On all supported OS/Platforms, the following PHP versions can be set up as per the runner.

  • PHP 5.3 to PHP 8.6 on GitHub-hosted runners, except for macOS ARM64 runners (macos-14).
  • PHP 5.6 to PHP 8.6 on GitHub-hosted macOS ARM64 runners (macos-14).
  • PHP 5.6 to PHP 8.6 on self-hosted runners.
PHP Version Stability Release Support Runner Support
5.3 Stable End of life GitHub-hosted
5.4 Stable End of life GitHub-hosted
5.5 Stable End of life GitHub-hosted
5.6 Stable End of life GitHub-hosted, self-hosted
7.0 Stable End of life GitHub-hosted, self-hosted
7.1 Stable End of life GitHub-hosted, self-hosted
7.2 Stable End of life GitHub-hosted, self-hosted
7.3 Stable End of life GitHub-hosted, self-hosted
7.4 Stable End of life GitHub-hosted, self-hosted
8.0 Stable End of life GitHub-hosted, self-hosted
8.1 Stable End of life GitHub-hosted, self-hosted
8.2 Stable Security fixes only GitHub-hosted, self-hosted
8.3 Stable Security fixes only GitHub-hosted, self-hosted
8.4 Stable Active GitHub-hosted, self-hosted
8.5 Stable Active GitHub-hosted, self-hosted
8.6 Nightly In development GitHub-hosted, self-hosted

[!Note] - Specifying 8.6 in php-version input installs a nightly build of PHP 8.6.0-dev from the master branch of PHP. See nightly build setup for more information. - To use JIT on PHP 8.0 and above, refer to the JIT configuration section.

:heavy_plus_sign: PHP Extension Support

PHP extensions can be set up using the extensions input. It accepts a string in csv-format.

  • On Ubuntu, extensions which are available as a package, available on PECL or a git repository can be set up.
- name: Setup PHP with PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'
    extensions: imagick, redis
  • On Windows, extensions available on PECL which have the DLL binary can be set up.

  • On macOS, extensions available on PECL or a git repository can be set up.

  • On Ubuntu and macOS to compile and install an extension from a git repository follow this guide.

  • Extensions installed along with PHP if specified are enabled.

  • Specific versions of extensions available on PECL can be set up by suffixing the extension's name with the version. This is useful for installing old versions of extensions which support end of life PHP versions.

- name: Setup PHP with specific version of PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '5.4'
    extensions: swoole-1.9.3
  • Extensions with pre-release versions available on PECL can be set up by suffixing the extension's name with its state i.e alpha, beta, devel or snapshot.
- name: Setup PHP with pre-release PECL extension
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'
    extensions: xdebug-beta
  • On Ubuntu and macOS to compile and install an extension from PECL with libraries or custom configuration follow this guide.

  • Shared extensions can be disabled by prefixing them with a :. All extensions depending on the specified extension will also be disabled.

- name: Setup PHP and disable opcache
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'
    extensions: :mbstring
  • All shared extensions can be disabled by specifying none. When none is specified along with other extensions, it is hoisted to the start of the input. So, all the shared extensions will be disabled first, then rest of the extensions in the input will be processed.

This disables all core and third-party shared extensions and thus, can break some tools that need them. Required extensions are enabled again when the tools are set up on a best-effort basis. So it is recommended to add the extensions required for your tools after none in the extensions input to avoid any issues.

- name: Setup PHP without any shared extensions except mbstring
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'
    extensions: none, mbstring
  • Extension intl can be set up with specific ICU version for PHP 5.6 and above in Ubuntu workflows by suffixing intl with the ICU version. ICU 50.2 and newer versions are supported for PHP 8.4 and lower, ICU 57.2 and newer versions are supported for PHP 8.5 and above. Refer to ICU builds for the specific versions supported.
- name: Setup PHP with intl
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'
    extensions: intl-77.1
  • Extensions loaded by default after setup-php runs can be found on the wiki.

  • These extensions have custom support:

  • cubrid and pdo_cubrid on Ubuntu.
  • event, gearman, geos and relay on Ubuntu and macOS.
  • blackfire, couchbase, ibm_db2, ioncube, oci8, pdo_firebird, pdo_ibm, pdo_oci, pecl_http, phalcon3, phalcon4, phalcon5, and zephir_parser on all supported OS.

  • By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set fail-fast flag to true.

- name: Setup PHP with fail-fast
  uses: shivammathur/setup-php@v2
  with:
    php-version: '8.5'
    extensions: oci8
  env:
    fail-fast: true

:wrench: Tools Support

These tools can be set up globally using the tools input. It accepts a string in csv-format.

[backward-compatibility-check], [behat], [blackfire], [blackfire-player], [box], [castor], [churn], [codeception], [composer], [composer-dependency-analyser], [composer-normalize], [composer-prefetcher], [composer-require-checker], [composer-unused], [cs2pr], [deployer], [ecs], [flex], [grpc_php_plugin], [infection], [mago], [name-collision-detector], [parallel-lint], [pecl], [phan], [phing], [phinx], [phive], [php-config], [php-cs-fixer], [php-scoper], [phpcbf], [phpcpd], [phpcs], [phpdoc] or [phpDocumentor], [phpize], [phplint], [phpmd], [phpspec], [phpstan], [phpunit], [phpunit-bridge], [phpunit-polyfills], [pie], [pint], [prestissimo], [protoc], [psalm], [rector], [symfony] or [symfony-cli], [vapor] or [vapor-cli], [wp] or [wp-cli]

```yaml - name: Setup PHP with tools uses: shivam

Extension points exported contracts — how you extend this code

ToolConfig (Interface)
* Partial tool data from tools.json configuration
src/tools.ts
CommandProperties (Interface)
* Commands * * Command Format: * ::name key=value,key=value::message * * @see https://docs.github.com/en/actions/
src/core.ts
GitHubRef (Interface)
* GitHub reference object from API response
src/tools.ts
DeployerManifestEntry (Interface)
* Deployer manifest entry
src/tools.ts
ToolData (Interface)
(no doc)
src/tools.ts

Core symbols most depended-on inside this repo

addArchive
called by 9
src/tools.ts
log
called by 6
src/utils.ts
getUrl
called by 5
src/tools.ts
escapeForShell
called by 5
src/utils.ts
validatePHPVersionInput
called by 4
src/utils.ts
getLatestVersion
called by 2
src/tools.ts
getPharUrl
called by 2
src/tools.ts
readEnv
called by 2
src/utils.ts

Shape

Function 77
Interface 5

Languages

TypeScript100%

Modules by API surface

src/tools.ts28 symbols
src/utils.ts27 symbols
src/core.ts8 symbols
src/coverage.ts5 symbols
src/extensions.ts4 symbols
src/install.ts3 symbols
src/config.ts3 symbols
__tests__/tools.test.ts2 symbols
src/packagist.ts1 symbols
src/fetch.ts1 symbols

Dependencies from manifests, versioned

@actions/exec2.0.0 · 1×
@eslint/compat2.1.0 · 1×
@eslint/js10.0.1 · 1×
@types/jest30.0.0 · 1×
@types/node25.9.2 · 1×
@typescript-eslint/eslint-plugin8.60.1 · 1×
@typescript-eslint/parser8.60.1 · 1×
@vercel/ncc0.38.4 · 1×
compare-versions6.1.1 · 1×
eslint10.4.1 · 1×
eslint-config-prettier10.1.8 · 1×
eslint-import-resolver-typescript4.4.5 · 1×

Datastores touched

(mysql)Database · 1 repos

For agents

$ claude mcp add setup-php \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact