|
|
|
@@ -18,7 +18,7 @@
|
|
|
|
|
<a href="https://status.setup-php.com" title="setup-php status"><img alt="setup-php status" src="https://img.shields.io/badge/status-subscribe-28A745?logo=statuspage&logoColor=28A745&labelColor=555555"></a>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "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](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
|
|
|
|
Setup PHP with required extensions, php.ini configuration, code-coverage support, and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross-platform interface to set up the PHP environment you need to test your application. Refer to the [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
|
|
|
|
|
|
|
|
|
## Contents
|
|
|
|
|
|
|
|
|
@@ -70,8 +70,10 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
|
|
|
|
|
|
|
|
|
| Virtual environment | Arch | YAML workflow label | Pre-installed PHP |
|
|
|
|
|
|---------------------|---------|------------------------------------|-------------------|
|
|
|
|
|
| Ubuntu 26.04 | x86_64 | `ubuntu-26.04` | `PHP 8.5` |
|
|
|
|
|
| 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 26.04 | aarch64 | `ubuntu-26.04-arm` | `PHP 8.5` |
|
|
|
|
|
| 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` |
|
|
|
|
@@ -86,6 +88,7 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
|
|
|
|
|
|
|
|
|
| Host OS/Virtual environment | YAML workflow label |
|
|
|
|
|
|----------------------------------|----------------------------|
|
|
|
|
|
| Ubuntu 26.04 | `self-hosted` or `Linux` |
|
|
|
|
|
| Ubuntu 24.04 | `self-hosted` or `Linux` |
|
|
|
|
|
| Ubuntu 22.04 | `self-hosted` or `Linux` |
|
|
|
|
|
| Debian 13 | `self-hosted` or `Linux` |
|
|
|
|
@@ -98,7 +101,7 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
|
|
|
|
| macOS Sonoma 14.x x86_64/arm64 | `self-hosted` or `macOS` |
|
|
|
|
|
|
|
|
|
|
- Refer to the [self-hosted setup](#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.
|
|
|
|
|
- Operating systems based on the above Ubuntu and Debian versions are also supported on a 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
|
|
|
|
@@ -155,7 +158,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|
|
|
|
|
|
|
|
|
- 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.
|
|
|
|
|
- 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.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
- name: Setup PHP with specific version of PECL extension
|
|
|
|
@@ -180,14 +183,14 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|
|
|
|
- Shared extensions can be disabled by prefixing them with a `:`. All extensions depending on the specified extension will also be disabled.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
- name: Setup PHP and disable opcache
|
|
|
|
|
- name: Setup PHP and disable mbstring
|
|
|
|
|
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.
|
|
|
|
|
- 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 the 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.
|
|
|
|
|
|
|
|
|
@@ -216,7 +219,7 @@ This disables all core and third-party shared extensions and thus, can break som
|
|
|
|
|
- `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`.
|
|
|
|
|
- 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`.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
- name: Setup PHP with fail-fast
|
|
|
|
@@ -242,7 +245,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
|
|
|
|
tools: php-cs-fixer, phpunit
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- In addition to above tools any composer tool or package can also be set up globally by specifying it as `vendor/package` matching the listing on Packagist. This format accepts the same [version constraints](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints "Composer version constraints") as `composer`.
|
|
|
|
|
- In addition to the above tools, any composer tool or package can also be set up globally by specifying it as `vendor/package` matching the listing on Packagist. This format accepts the same [version constraints](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints "Composer version constraints") as `composer`.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
- name: Setup PHP with tools
|
|
|
|
@@ -342,7 +345,7 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- When you specify `coverage: xdebug`, the latest version of Xdebug compatible with the PHP version is set up by default.
|
|
|
|
|
- If you need Xdebug 2.x on PHP 7.2, 7.3 or 7.4, you can specify `coverage: xdebug2`.
|
|
|
|
|
- If you need Xdebug 2.x on PHP 7.2, 7.3, or 7.4, you can specify `coverage: xdebug2`.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
- name: Setup PHP with Xdebug 2.x
|
|
|
|
@@ -353,7 +356,7 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> [!NOTE]
|
|
|
|
|
> Xdebug is enabled by default on Ubuntu GitHub Actions images, so if you are not using it in your workflow it is recommended to disable it as that will have a positive impact on your PHP performance. Please refer to the [disable coverage](#disable-coverage) section for details.
|
|
|
|
|
> Xdebug is enabled by default on Ubuntu GitHub Actions images, so if you are not using it in your workflows, it is recommended to disable it as that will have a positive impact on your PHP performance. Please refer to the [disable coverage](#disable-coverage) section for details.
|
|
|
|
|
|
|
|
|
|
### PCOV
|
|
|
|
|
|
|
|
|
@@ -372,7 +375,7 @@ Runs on PHP 7.1 and newer PHP versions.
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- PHPUnit 8.x and above support PCOV out of the box.
|
|
|
|
|
- If you are using PHPUnit 5.x, 6.x or 7.x, you need to set up `pcov/clobber` before executing your tests.
|
|
|
|
|
- If you are using PHPUnit 5.x, 6.x, or 7.x, you need to set up `pcov/clobber` before executing your tests.
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
|