setup-php 2.12.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +977 -936
  3. package/package.json +66 -56
  4. package/src/config.ts +82 -82
  5. package/src/configs/brew_extensions +30 -0
  6. package/src/configs/os_releases.csv +17 -0
  7. package/src/configs/php-versions.json +6 -5
  8. package/src/configs/{php.json → pm/php.json} +29 -29
  9. package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
  10. package/src/configs/tools.json +256 -234
  11. package/src/configs/tools_schema.json +114 -103
  12. package/src/coverage.ts +169 -142
  13. package/src/extensions.ts +363 -349
  14. package/src/install.ts +79 -82
  15. package/src/scripts/common.sh +366 -314
  16. package/src/scripts/darwin.sh +257 -248
  17. package/src/scripts/ext/blackfire.ps1 +32 -32
  18. package/src/scripts/ext/blackfire.sh +22 -21
  19. package/src/scripts/ext/couchbase.sh +43 -43
  20. package/src/scripts/ext/cubrid.sh +60 -60
  21. package/src/scripts/ext/extension_map.php +109 -0
  22. package/src/scripts/ext/firebird.ps1 +19 -19
  23. package/src/scripts/ext/firebird.sh +39 -35
  24. package/src/scripts/ext/gearman.sh +22 -22
  25. package/src/scripts/ext/geos.sh +17 -17
  26. package/src/scripts/ext/http.ps1 +54 -54
  27. package/src/scripts/ext/http.sh +120 -120
  28. package/src/scripts/ext/intl.sh +23 -23
  29. package/src/scripts/ext/ioncube.ps1 +33 -32
  30. package/src/scripts/ext/ioncube.sh +21 -19
  31. package/src/scripts/ext/oci.ps1 +60 -60
  32. package/src/scripts/ext/oci.sh +65 -63
  33. package/src/scripts/ext/patches/firebird.sh +11 -11
  34. package/src/scripts/ext/patches/geos.sh +7 -7
  35. package/src/scripts/ext/patches/http.sh +11 -11
  36. package/src/scripts/ext/patches/pdo_oci.sh +6 -6
  37. package/src/scripts/ext/patches/phpize.sh +26 -26
  38. package/src/scripts/ext/patches/protobuf.sh +4 -4
  39. package/src/scripts/ext/phalcon.ps1 +54 -55
  40. package/src/scripts/ext/phalcon.sh +59 -59
  41. package/src/scripts/ext/source.sh +144 -144
  42. package/src/scripts/linux.sh +239 -280
  43. package/src/scripts/tools/add_tools.ps1 +28 -25
  44. package/src/scripts/tools/add_tools.sh +27 -19
  45. package/src/scripts/tools/blackfire.ps1 +19 -21
  46. package/src/scripts/tools/blackfire.sh +40 -35
  47. package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
  48. package/src/scripts/tools/grpc_php_plugin.sh +58 -61
  49. package/src/scripts/tools/ppa.sh +189 -0
  50. package/src/scripts/tools/protoc.ps1 +38 -38
  51. package/src/scripts/tools/protoc.sh +28 -28
  52. package/src/scripts/win32.ps1 +566 -471
  53. package/src/tools.ts +538 -509
  54. package/src/utils.ts +503 -497
  55. package/.eslintrc.json +0 -16
  56. package/.github/CODE_OF_CONDUCT.md +0 -76
  57. package/.github/CONTRIBUTING.md +0 -70
  58. package/.github/FUNDING.yml +0 -7
  59. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
  60. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  61. package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
  62. package/.github/SECURITY.md +0 -29
  63. package/.github/workflows/docs.yml +0 -77
  64. package/.github/workflows/node-workflow.yml +0 -51
  65. package/.github/workflows/workflow.yml +0 -78
  66. package/.idea/workspace.xml +0 -113
  67. package/.prettierrc.json +0 -12
  68. package/__tests__/config.test.ts +0 -52
  69. package/__tests__/coverage.test.ts +0 -110
  70. package/__tests__/extensions.test.ts +0 -261
  71. package/__tests__/install.test.ts +0 -175
  72. package/__tests__/tools.test.ts +0 -490
  73. package/__tests__/utils.test.ts +0 -303
  74. package/action.yml +0 -29
  75. package/dist/index.js +0 -3001
  76. package/examples/bedrock.yml +0 -32
  77. package/examples/blackfire-player.yml +0 -31
  78. package/examples/blackfire.yml +0 -31
  79. package/examples/cakephp-mysql.yml +0 -114
  80. package/examples/cakephp-postgres.yml +0 -112
  81. package/examples/cakephp.yml +0 -92
  82. package/examples/codeigniter.yml +0 -34
  83. package/examples/laravel-mysql.yml +0 -74
  84. package/examples/laravel-postgres.yml +0 -74
  85. package/examples/laravel.yml +0 -42
  86. package/examples/lumen-mysql.yml +0 -74
  87. package/examples/lumen-postgres.yml +0 -74
  88. package/examples/lumen.yml +0 -38
  89. package/examples/phalcon-mysql.yml +0 -74
  90. package/examples/phalcon-postgres.yml +0 -73
  91. package/examples/sage.yml +0 -57
  92. package/examples/slim-framework.yml +0 -34
  93. package/examples/symfony-mysql.yml +0 -57
  94. package/examples/symfony-postgres.yml +0 -55
  95. package/examples/symfony.yml +0 -39
  96. package/examples/yii2-mysql.yml +0 -73
  97. package/examples/yii2-postgres.yml +0 -71
  98. package/examples/zend-framework.yml +0 -36
  99. package/jest.config.js +0 -12
  100. package/lib/config.js +0 -72
  101. package/lib/config.js.map +0 -1
  102. package/lib/coverage.js +0 -88
  103. package/lib/coverage.js.map +0 -1
  104. package/lib/extensions.js +0 -201
  105. package/lib/extensions.js.map +0 -1
  106. package/lib/install.js +0 -82
  107. package/lib/install.js.map +0 -1
  108. package/lib/sapi.js +0 -64
  109. package/lib/tools.js +0 -387
  110. package/lib/tools.js.map +0 -1
  111. package/lib/utils.js +0 -292
  112. package/lib/utils.js.map +0 -1
  113. package/tsconfig.json +0 -18
package/README.md CHANGED
@@ -1,936 +1,977 @@
1
- <p align="center">
2
- <a href="https://github.com/marketplace/actions/setup-php-action" target="_blank">
3
- <img src="https://repository-images.githubusercontent.com/206578964/e0a18480-dc65-11e9-8dd3-b9ffbf5575fe" alt="Setup PHP in GitHub Actions" width="400">
4
- </a>
5
- </p>
6
-
7
- <h1 align="center">Setup PHP in GitHub Actions</h1>
8
-
9
- <p align="center">
10
- <a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
11
- <a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
12
- <a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
13
- <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.1-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
14
- </p>
15
- <p align="center">
16
- <a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
17
- <a href="https://twitter.com/setup_php" title="setup-php twitter"><img alt="setup-php twitter" src="https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555"></a>
18
- <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>
19
- </p>
20
-
21
- 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.
22
-
23
- ## Contents
24
-
25
- - [OS/Platform Support](#cloud-osplatform-support)
26
- - [GitHub-Hosted Runners](#github-hosted-runners)
27
- - [Self-Hosted Runners](#self-hosted-runners)
28
- - [PHP Support](#tada-php-support)
29
- - [PHP Extension Support](#heavy_plus_sign-php-extension-support)
30
- - [Tools Support](#wrench-tools-support)
31
- - [Coverage Support](#signal_strength-coverage-support)
32
- - [Xdebug](#xdebug)
33
- - [PCOV](#pcov)
34
- - [Disable Coverage](#disable-coverage)
35
- - [Usage](#memo-usage)
36
- - [Inputs](#inputs)
37
- - [Outputs](#outputs)
38
- - [Flags](#flags)
39
- - [Basic Setup](#basic-setup)
40
- - [Matrix Setup](#matrix-setup)
41
- - [Nightly Build Setup](#nightly-build-setup)
42
- - [Thread Safe Setup](#thread-safe-setup)
43
- - [Force Update Setup](#force-update-setup)
44
- - [Verbose Setup](#verbose-setup)
45
- - [Multi-Arch Setup](#multi-arch-setup)
46
- - [Self Hosted Setup](#self-hosted-setup)
47
- - [Local Testing Setup](#local-testing-setup)
48
- - [JIT Configuration](#jit-configuration)
49
- - [Cache Extensions](#cache-extensions)
50
- - [Cache Composer Dependencies](#cache-composer-dependencies)
51
- - [Cache Node.js Dependencies](#cache-nodejs-dependencies)
52
- - [Composer GitHub OAuth](#composer-github-oauth)
53
- - [Problem Matchers](#problem-matchers)
54
- - [Examples](#examples)
55
- - [Versioning](#bookmark-versioning)
56
- - [License](#scroll-license)
57
- - [Contributions](#1-contributions)
58
- - [Support This Project](#sparkling_heart-support-this-project)
59
- - [Dependencies](#package-dependencies)
60
- - [Further Reading](#bookmark_tabs-further-reading)
61
-
62
- ## :cloud: OS/Platform Support
63
-
64
- Both `GitHub-hosted` and `self-hosted` runners are suppported by `setup-php` on the following OS/Platforms.
65
-
66
- ### GitHub-Hosted Runners
67
-
68
- |Virtual environment|YAML workflow label|Pre-installed PHP|
69
- |--- |--- |--- |
70
- |Ubuntu 18.04|`ubuntu-18.04`|`PHP 7.1` to `PHP 8.0`|
71
- |Ubuntu 20.04|`ubuntu-latest` or `ubuntu-20.04`|`PHP 7.4` to `PHP 8.0`|
72
- |Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 8.0`|
73
- |macOS Catalina 10.15|`macos-latest` or `macos-10.15`|`PHP 8.0`|
74
- |macOS Big Sur 11.x|`macos-11.0`|`PHP 8.0`|
75
-
76
- ### Self-Hosted Runners
77
-
78
- |Host OS/Virtual environment|YAML workflow label|
79
- |--- |--- |
80
- |Ubuntu 18.04|`self-hosted` or `Linux`|
81
- |Ubuntu 20.04|`self-hosted` or `Linux`|
82
- |Windows 7 and newer|`self-hosted` or `Windows`|
83
- |Windows Server 2012 R2 and newer|`self-hosted` or `Windows`|
84
- |macOS Catalina 10.15|`self-hosted` or `macOS`|
85
- |macOS Big Sur 11.x x86_64/arm64|`self-hosted` or `macOS`|
86
-
87
- - Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
88
- - If the requested PHP version is pre-installed, `setup-php` switches to it, otherwise it installs the PHP version.
89
-
90
- ## :tada: PHP Support
91
-
92
- On all supported OS/Platforms the following PHP versions are supported as per the runner.
93
-
94
- - PHP 5.3 to PHP 8.1 on GitHub-hosted runners.
95
- - PHP 5.6 to PHP 8.1 on self-hosted runners.
96
-
97
- |PHP Version|Stability|Release Support|Runner Support|
98
- |--- |--- |--- |--- |
99
- |`5.3`|`Stable`|`End of life`|`GitHub-hosted`|
100
- |`5.4`|`Stable`|`End of life`|`GitHub-hosted`|
101
- |`5.5`|`Stable`|`End of life`|`GitHub-hosted`|
102
- |`5.6`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
103
- |`7.0`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
104
- |`7.1`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
105
- |`7.2`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
106
- |`7.3`|`Stable`|`Security fixes only`|`GitHub-hosted`, `self-hosted`|
107
- |`7.4`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
108
- |`8.0`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
109
- |`8.1`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`|
110
-
111
- **Notes:**
112
- - Specifying `8.1` in `php-version` input installs a nightly build of `PHP 8.1.0-dev`. See [nightly build setup](#nightly-build-setup) for more information.
113
- - To use JIT on `PHP 8.0` and `PHP 8.1` refer to the [JIT configuration](#jit-configuration) section.
114
-
115
- ## :heavy_plus_sign: PHP Extension Support
116
-
117
- PHP extensions can be setup using the `extensions` input. It accepts a `string` in csv-format.
118
-
119
- - On `Ubuntu`, extensions which are available as a package, available on `PECL` or a git repository can be set up.
120
-
121
- ```yaml
122
- - name: Setup PHP with PECL extension
123
- uses: shivammathur/setup-php@v2
124
- with:
125
- php-version: '7.4'
126
- extensions: imagick, swoole
127
- ```
128
-
129
- - On `Windows`, extensions available on `PECL` which have the `DLL` binary can be set up.
130
-
131
- - On `macOS`, extensions available on `PECL` or a git repository can be set up.
132
-
133
- - On `Ubuntu` and `macOS` to compile and install an extension from a git repository follow this [guide](https://github.com/shivammathur/setup-php/wiki/Add-extension-from-source "Guide to compile and install PHP extensions in setup-php").
134
-
135
- - Extensions installed along with PHP if specified are enabled.
136
-
137
- - Specific versions of extensions available on `PECL` can be setup 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.
138
-
139
- ```yaml
140
- - name: Setup PHP with specific version of PECL extension
141
- uses: shivammathur/setup-php@v2
142
- with:
143
- php-version: '5.4'
144
- extensions: swoole-1.9.3
145
- ```
146
-
147
- - Pre-release versions extensions available on `PECL` can be setup by suffixing the extension's name with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
148
-
149
- ```yaml
150
- - name: Setup PHP with pre-release PECL extension
151
- uses: shivammathur/setup-php@v2
152
- with:
153
- php-version: '7.4'
154
- extensions: xdebug-beta
155
- ```
156
-
157
- - Shared extensions can be removed by prefixing them with a `:`.
158
-
159
- ```yaml
160
- - name: Setup PHP and remove shared extension
161
- uses: shivammathur/setup-php@v2
162
- with:
163
- php-version: '7.4'
164
- extensions: :opcache
165
- ```
166
-
167
- - Extension `intl` can be setup 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. Refer to [`ICU builds`](https://github.com/shivammathur/icu-intl#icu4c-builds) for the specific versions supported.
168
-
169
- ```yaml
170
- - name: Setup PHP with intl
171
- uses: shivammathur/setup-php@v2
172
- with:
173
- php-version: '7.4'
174
- extensions: intl-69.1
175
- ```
176
-
177
- - Extensions loaded by default after `setup-php` runs can be found on the [wiki](https://github.com/shivammathur/setup-php/wiki).
178
-
179
- - These extensions have custom support:
180
- - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`.
181
- - `geos` on `Ubuntu` and `macOS`.
182
- - `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3` and `phalcon4` on all supported OS.
183
-
184
- - By default, extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
185
-
186
- ```yaml
187
- - name: Setup PHP with fail-fast
188
- uses: shivammathur/setup-php@v2
189
- with:
190
- php-version: '7.4'
191
- extensions: oci8
192
- env:
193
- fail-fast: true
194
- ```
195
-
196
- ## :wrench: Tools Support
197
-
198
- These tools can be setup globally using the `tools` input. It accepts a string in csv-format.
199
-
200
- `behat`, `blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phing`, `phinx`, `phive`, `php-config`, `php-cs-fixer`, `phpcbf`, `phpcpd`, `phpcs`, `phpize`, `phplint`, `phpmd`, `phpspec`, `phpstan`, `phpunit`, `phpunit-bridge`, `prestissimo`, `protoc`, `psalm`, `symfony` or `symfony-cli`, `vapor` or `vapor-cli`, `wp` or `wp-cli`
201
-
202
- ```yaml
203
- - name: Setup PHP with tools
204
- uses: shivammathur/setup-php@v2
205
- with:
206
- php-version: '7.4'
207
- tools: php-cs-fixer, phpunit
208
- ```
209
-
210
- - 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`.
211
-
212
- ```yaml
213
- - name: Setup PHP with tools
214
- uses: shivammathur/setup-php@v2
215
- with:
216
- php-version: '7.4'
217
- tools: vimeo/psalm
218
- ```
219
-
220
- - To set up a particular version of a tool, specify it in the form `tool:version`.
221
-
222
- Version can be in the following format:
223
- - Semver. For example `tool:1.2.3` or `tool:1.2.3-beta1`.
224
- - Major version. For example `tool:1` or `tool:1.x`.
225
- - Major and minor version. For example `tool:1.2` or `tool:1.2.x`.
226
-
227
- When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup.
228
-
229
- Except for major versions of `composer`, For other tools when you specify only the `major` version or the version in `major.minor` format for any tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a [`GitHub` OAuth token](https://github.com/shivammathur/setup-php#composer-github-oauth "Composer GitHub OAuth"). You can do that by setting `COMPOSER_TOKEN` environment variable.
230
-
231
- ```yaml
232
- - name: Setup PHP with tools
233
- uses: shivammathur/setup-php@v2
234
- with:
235
- php-version: '7.4'
236
- tools: php-cs-fixer:3, phpunit:8.5
237
- env:
238
- COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
239
- ```
240
-
241
- - The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format, Additionally for composer `snapshot` and `preview` can also be specified to set up the respective releases.
242
-
243
- ```yaml
244
- - name: Setup PHP with composer v2
245
- uses: shivammathur/setup-php@v2
246
- with:
247
- php-version: '7.4'
248
- tools: composer:v2
249
- ```
250
-
251
- - If you do not use composer in your workflow, you can specify `tools: none` to skip it.
252
-
253
- ```yaml
254
- - name: Setup PHP without composer
255
- uses: shivammathur/setup-php@v2
256
- with:
257
- php-version: '7.4'
258
- tools: none
259
- ```
260
-
261
- - Scripts `phpize` and `php-config` are set up with the same version as of the input PHP version.
262
-
263
- - The latest versions of both agent `blackfire-agent` and client `blackfire` are set up when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.
264
-
265
- - Tools `prestissimo` and `composer-prefetcher` will be skipped unless `composer:v1` is also specified in tools input. It is recommended to drop `prestissimo` and use `composer v2`.
266
-
267
- - By default, tools which cannot be set up gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
268
-
269
- ```yaml
270
- - name: Setup PHP with fail-fast
271
- uses: shivammathur/setup-php@v2
272
- with:
273
- php-version: '7.4'
274
- tools: deployer
275
- env:
276
- fail-fast: true
277
- ```
278
-
279
- **Notes**
280
- - Input `tools` is useful to set up tools which you only use in GitHub Actions, thus keeping your `composer.json` tidy.
281
- - If you do not want to use all your dev-dependencies in GitHub Actions workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
282
- - If you have a tool in your `composer.json`, do not set up it with `tools` input as the two instances of the tool might conflict.
283
-
284
- ## :signal_strength: Coverage Support
285
-
286
- ### Xdebug
287
-
288
- Specify `coverage: xdebug` to use `Xdebug` and disable `PCOV`.
289
- Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
290
-
291
- ```yaml
292
- - name: Setup PHP with Xdebug
293
- uses: shivammathur/setup-php@v2
294
- with:
295
- php-version: '7.4'
296
- coverage: xdebug
297
- ```
298
-
299
- - The latest version of Xdebug compatible with the PHP version is set up by default.
300
- - If you need Xdebug 2.x on PHP 7.2, 7.3 or 7.4, you can specify `coverage: xdebug2`.
301
-
302
- ```yaml
303
- - name: Setup PHP with Xdebug 2.x
304
- uses: shivammathur/setup-php@v2
305
- with:
306
- php-version: '7.4'
307
- coverage: xdebug2
308
- ```
309
-
310
- ### PCOV
311
-
312
- Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`.
313
- Runs on PHP 7.1 and newer PHP versions.
314
-
315
- - If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
316
-
317
- ```yaml
318
- - name: Setup PHP with PCOV
319
- uses: shivammathur/setup-php@v2
320
- with:
321
- php-version: '7.4'
322
- ini-values: pcov.directory=api #optional, see above for usage.
323
- coverage: pcov
324
- ```
325
-
326
- - PHPUnit 8.x and above supports PCOV out of the box.
327
- - If you are using PHPUnit 5.x, 6.x or 7.x, you need to set up `pcov/clobber` before executing your tests.
328
-
329
- ```yaml
330
- - name: Setup PCOV
331
- run: |
332
- composer require pcov/clobber
333
- vendor/bin/pcov clobber
334
- ```
335
-
336
- ### Disable Coverage
337
-
338
- Specify `coverage: none` to remove both `Xdebug` and `PCOV`.
339
-
340
- Disable coverage for these reasons:
341
-
342
- - You are not generating coverage reports while testing.
343
- - It will remove `Xdebug`, which will have a positive impact on PHP performance.
344
- - You are using `phpdbg` for running your tests.
345
- - You are profiling your code using `blackfire`.
346
- - You are using PHP in JIT mode. Please refer to [JIT configuration](#jit-configuration) section for more details.
347
-
348
- ```yaml
349
- - name: Setup PHP with no coverage driver
350
- uses: shivammathur/setup-php@v2
351
- with:
352
- php-version: '7.4'
353
- coverage: none
354
- ```
355
-
356
- ## :memo: Usage
357
-
358
- ### Inputs
359
-
360
- > Specify using `with` keyword
361
-
362
- #### `php-version` (required)
363
-
364
- - Specify the PHP version you want to set up.
365
- - Accepts a `string`. For example `'7.4'`.
366
- - Accepts `latest` to set up the latest stable PHP version.
367
- - Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
368
- - See [PHP support](#tada-php-support) for supported PHP versions.
369
-
370
- #### `extensions` (optional)
371
-
372
- - Specify the extensions you want to add or remove.
373
- - Accepts a `string` in csv-format. For example `mbstring, :opcache`.
374
- - Non-default extensions prefixed with `:` are removed.
375
- - See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info.
376
-
377
- #### `ini-values` (optional)
378
-
379
- - Specify the values you want to add to `php.ini`.
380
- - Accepts a `string` in csv-format. For example `post_max_size=256M, max_execution_time=180`.
381
- - Accepts ini values with commas if wrapped in quotes. For example `xdebug.mode="develop,coverage"`.
382
-
383
- #### `coverage` (optional)
384
-
385
- - Specify the code coverage driver you want to set up.
386
- - Accepts `xdebug`, `pcov` or `none`.
387
- - See [coverage support](#signal_strength-coverage-support) for more info.
388
-
389
- #### `tools` (optional)
390
-
391
- - Specify the tools you want to set up.
392
- - Accepts a `string` in csv-format. For example: `phpunit, phpcs`
393
- - See [tools Support](#wrench-tools-support) for tools supported.
394
-
395
- ### Outputs
396
-
397
- #### `php-version`
398
-
399
- To use outputs, give the `setup-php` step an `id`, you can use the same to get the outputs in a later step.
400
-
401
- - Provides the PHP version in semver format.
402
-
403
- ```yml
404
- - name: Setup PHP
405
- id: setup-php
406
- uses: shivammathur/setup-php@v2
407
- with:
408
- php-version: '7.4'
409
-
410
- - name: Print PHP version
411
- run: echo ${{ steps.setup-php.outputs.php-version }}
412
- ```
413
-
414
- ### Flags
415
-
416
- > Specify using `env` keyword
417
-
418
- #### `fail-fast` (optional)
419
-
420
- - Specify to mark the workflow as failed if an extension or tool fails to set up.
421
- - This changes the default mode from graceful warnings to fail-fast.
422
- - By default, it is set to `false`.
423
- - Accepts `true` and `false`.
424
-
425
- #### `phpts` (optional)
426
-
427
- - Specify to set up thread-safe version of PHP on Windows.
428
- - Accepts `ts` and `nts`.
429
- - By default, it is set to `nts`.
430
- - See [thread safe setup](#thread-safe-setup) for more info.
431
-
432
- #### `update` (optional)
433
-
434
- - Specify to update PHP on the runner to the latest patch version.
435
- - Accepts `true` and `false`.
436
- - By default, it is set to `false`.
437
- - See [force update setup](#force-update-setup) for more info.
438
-
439
- See below for more info.
440
-
441
- ### Basic Setup
442
-
443
- > Setup a particular PHP version.
444
-
445
- ```yaml
446
- steps:
447
- - name: Checkout
448
- uses: actions/checkout@v2
449
-
450
- - name: Setup PHP
451
- uses: shivammathur/setup-php@v2
452
- with:
453
- php-version: '7.4'
454
- extensions: mbstring, intl
455
- ini-values: post_max_size=256M, max_execution_time=180
456
- coverage: xdebug
457
- tools: php-cs-fixer, phpunit
458
- ```
459
-
460
- ### Matrix Setup
461
-
462
- > Setup multiple PHP versions on multiple operating systems.
463
-
464
- ```yaml
465
- jobs:
466
- run:
467
- runs-on: ${{ matrix.operating-system }}
468
- strategy:
469
- matrix:
470
- operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
471
- php-versions: ['7.3', '7.4']
472
- phpunit-versions: ['latest']
473
- include:
474
- - operating-system: 'ubuntu-latest'
475
- php-versions: '7.2'
476
- phpunit-versions: '8.5.13'
477
- steps:
478
- - name: Checkout
479
- uses: actions/checkout@v2
480
-
481
- - name: Setup PHP
482
- uses: shivammathur/setup-php@v2
483
- with:
484
- php-version: ${{ matrix.php-versions }}
485
- extensions: mbstring, intl
486
- ini-values: post_max_size=256M, max_execution_time=180
487
- coverage: xdebug
488
- tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
489
- ```
490
-
491
- ### Nightly Build Setup
492
-
493
- > Setup a nightly build of `PHP 8.1`.
494
-
495
- - This version is currently in development.
496
- - Some user space extensions might not support this version currently.
497
-
498
- ```yaml
499
- steps:
500
- - name: Checkout
501
- uses: actions/checkout@v2
502
-
503
- - name: Setup nightly PHP
504
- uses: shivammathur/setup-php@v2
505
- with:
506
- php-version: '8.1'
507
- extensions: mbstring
508
- ini-values: post_max_size=256M, max_execution_time=180
509
- coverage: xdebug
510
- tools: php-cs-fixer, phpunit
511
- ```
512
-
513
- ### Thread Safe Setup
514
-
515
- > Setup `TS` or `NTS` PHP on `Windows`.
516
-
517
- - `NTS` versions are setup by default.
518
- - On `Ubuntu` and `macOS` only `NTS` versions are supported.
519
- - On `Windows` both `TS` and `NTS` versions are supported.
520
-
521
- ```yaml
522
- jobs:
523
- run:
524
- runs-on: windows-latest
525
- name: Setup PHP TS on Windows
526
- steps:
527
- - name: Checkout
528
- uses: actions/checkout@v2
529
-
530
- - name: Setup PHP
531
- uses: shivammathur/setup-php@v2
532
- with:
533
- php-version: '7.4'
534
- env:
535
- phpts: ts # specify ts or nts
536
- ```
537
-
538
- ### Force Update Setup
539
-
540
- > Update to the latest patch of PHP versions.
541
-
542
- - Pre-installed PHP versions on the GitHub Actions images are not updated to their latest patch release by default.
543
- - You can specify the `update` environment variable to `true` for updating to the latest release.
544
-
545
- ```yaml
546
- - name: Setup PHP with latest versions
547
- uses: shivammathur/setup-php@v2
548
- with:
549
- php-version: '7.4'
550
- env:
551
- update: true # specify true or false
552
- ```
553
-
554
- ### Verbose Setup
555
-
556
- > Debug your workflow
557
-
558
- To debug any issues, you can use the `verbose` tag instead of `v2`.
559
-
560
- ```yaml
561
- - name: Setup PHP with logs
562
- uses: shivammathur/setup-php@verbose
563
- with:
564
- php-version: '7.4'
565
- ```
566
-
567
- ### Multi-Arch Setup
568
-
569
- > Setup PHP on multiple architecture on Ubuntu GitHub Runners.
570
-
571
- - `PHP 5.6` to `PHP 8.0` are supported by `setup-php` on multiple architecture on `Ubuntu`.
572
- - For this, you can use `shivammathur/node` images as containers. These have compatible `Nodejs` and `spc` utility.
573
- - Using `spc` you can run `setup-php` on both `i386` and `amd64` containers as opposed to [default syntax](#basic-setup), which only supports `amd64`.
574
- - Currently, for `Arm` based setup, you will need [self-hosted runners](#self-hosted-setup).
575
-
576
- ```yaml
577
- jobs:
578
- run:
579
- runs-on: ubuntu-latest
580
- container: shivammathur/node:latest-${{ matrix.arch }}
581
- strategy:
582
- matrix:
583
- arch: ["amd64", "i386"]
584
- steps:
585
- - name: Install PHP
586
- run: |
587
- # Update spc (See https://github.com/shivammathur/spc for options)
588
- spc -U
589
-
590
- # Install PHP
591
- spc --php-version "7.4" \
592
- --extensions "mbstring, intl" \
593
- --ini-values "post_max_size=256M, max_execution_time=180" \
594
- --coverage "xdebug" \
595
- --tools "php-cs-fixer, phpunit"
596
- ```
597
-
598
- ### Self Hosted Setup
599
-
600
- > Setup PHP on a self-hosted runner.
601
-
602
- - To set up a dockerized self-hosted runner, refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Ubuntu) to set up in an `Ubuntu` container and refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Windows) to set up in a `Windows` container.
603
- - To set up the runner directly on the host OS or in a virtual machine, follow this [requirements guide](https://github.com/shivammathur/setup-php/wiki/Requirements-for-self-hosted-runners "Requirements guide for self-hosted runner to run setup-php") before setting up the self-hosted runner.
604
- - If your workflow uses [service containers](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then setup the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container.
605
-
606
- Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail.
607
-
608
- ```yaml
609
- jobs:
610
- run:
611
- runs-on: self-hosted
612
- strategy:
613
- matrix:
614
- php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
615
- name: PHP ${{ matrix.php-versions }}
616
- steps:
617
- - name: Checkout
618
- uses: actions/checkout@v2
619
-
620
- - name: Setup PHP
621
- uses: shivammathur/setup-php@v2
622
- with:
623
- php-version: ${{ matrix.php-versions }}
624
- env:
625
- runner: self-hosted # Specify the runner.
626
- ```
627
-
628
- **Notes**
629
- - Do not set up multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other.
630
- - Do not set up self-hosted runners on the side on your development environment or your production server.
631
- - Avoid using the same labels for your `self-hosted` runners which are used by `GitHub-hosted` runners.
632
-
633
- ### Local Testing Setup
634
-
635
- > Test your `Ubuntu` workflow locally using [`nektos/act`](https://github.com/nektos/act "Project to test GitHub Actions locally").
636
-
637
- ```yaml
638
- jobs:
639
- run:
640
- runs-on: ubuntu-latest
641
- name: PHP 7.4 Test
642
- steps:
643
- - name: Checkout
644
- uses: actions/checkout@v2
645
-
646
- - name: Setup PHP
647
- uses: shivammathur/setup-php@v2
648
- with:
649
- php-version: 7.4
650
- ```
651
-
652
- Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker images.
653
-
654
- Choose the image tag which matches the `runs-on` property in your workflow. For example, if you are using `ubuntu-20.04` in your workflow, run `act -P ubuntu-20.04=shivammathur/node:20.04`.
655
-
656
- ```bash
657
- # For runs-on: ubuntu-latest
658
- act -P ubuntu-latest=shivammathur/node:latest
659
-
660
- # For runs-on: ubuntu-20.04
661
- act -P ubuntu-20.04=shivammathur/node:2004
662
-
663
- # For runs-on: ubuntu-18.04
664
- act -P ubuntu-18.04=shivammathur/node:1804
665
- ```
666
-
667
- ### JIT Configuration
668
-
669
- > Enable Just-in-time(JIT) on PHP 8.0 and PHP 8.1.
670
-
671
- - To enable JIT, enable `opcache` in cli mode by setting `opcache.enable_cli=1`.
672
- - JIT conflicts with `Xdebug`, `PCOV`, and other extensions which override `zend_execute_ex` function, so set `coverage: none` and remove any such extension if added.
673
- - By default, `opcache.jit=1235` and `opcache.jit_buffer_size=256M` are set which can be changed using `ini-values` input.
674
- - For detailed information about JIT related directives refer to the [`official PHP documentation`](https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit "opcache.jit documentation").
675
-
676
- For example to enable JIT in `tracing` mode with buffer size of `64 MB`.
677
-
678
- ```yaml
679
- - name: Setup PHP with JIT in tracing mode
680
- uses: shivammathur/setup-php@v2
681
- with:
682
- php-version: '8.0'
683
- coverage: none
684
- ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
685
- ```
686
-
687
- ### Cache Extensions
688
-
689
- You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to set up when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
690
- Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details.
691
-
692
- ### Cache Composer Dependencies
693
-
694
- If your project uses composer, you can persist the composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
695
-
696
- ```yaml
697
- - name: Get composer cache directory
698
- id: composer-cache
699
- run: echo "::set-output name=dir::$(composer config cache-files-dir)"
700
-
701
- - name: Cache dependencies
702
- uses: actions/cache@v2
703
- with:
704
- path: ${{ steps.composer-cache.outputs.dir }}
705
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
706
- restore-keys: ${{ runner.os }}-composer-
707
-
708
- - name: Install dependencies
709
- run: composer install --prefer-dist
710
- ```
711
-
712
- **Notes**
713
- - Please do not cache `vendor` directory using `action/cache` as that will have side effects.
714
- - If you do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
715
- ```yaml
716
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
717
- ```
718
-
719
- - If you support a range of `composer` dependencies and use `prefer-lowest` and `prefer-stable` options, you can store them in your matrix and add them to the keys.
720
- ```yaml
721
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.prefer }}-
722
- restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
723
- ```
724
-
725
- ### Cache Node.js Dependencies
726
-
727
- If your project has node.js dependencies, you can persist NPM or yarn cache directory. The cached files are available across check-runs and will reduce the workflow execution time.
728
-
729
- ```yaml
730
- - name: Get node.js cache directory
731
- id: node-cache-dir
732
- run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
733
-
734
- - name: Cache dependencies
735
- uses: actions/cache@v2
736
- with:
737
- path: ${{ steps.node-cache-dir.outputs.dir }}
738
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
739
- restore-keys: ${{ runner.os }}-node-
740
- ```
741
-
742
- **Note:** Please do not cache `node_modules` directory as that will have side effects.
743
-
744
- ### Composer GitHub OAuth
745
-
746
- If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in `major.minor` format, you can hit the rate limit. To avoid this you can specify an `OAuth` token by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
747
-
748
- ```yaml
749
- - name: Setup PHP
750
- uses: shivammathur/setup-php@v2
751
- with:
752
- php-version: '7.4'
753
- env:
754
- COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
755
- ```
756
-
757
- ### Problem Matchers
758
-
759
- Problem matchers are `json` configurations which identify errors and warnings in your logs and surface them prominently in the GitHub Actions UI by highlighting them and creating code annotations.
760
-
761
- #### PHP
762
-
763
- Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
764
-
765
- ```yaml
766
- - name: Setup problem matchers for PHP
767
- run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
768
- ```
769
-
770
- #### PHPUnit
771
-
772
- Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
773
-
774
- ```yaml
775
- - name: Setup problem matchers for PHPUnit
776
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
777
- ```
778
-
779
- #### PHPStan
780
-
781
- PHPStan supports error reporting in GitHub Actions, so it does not require problem matchers.
782
-
783
- ```yaml
784
- - name: Setup PHP
785
- uses: shivammathur/setup-php@v2
786
- with:
787
- php-version: '7.4'
788
- tools: phpstan
789
-
790
- - name: Run PHPStan
791
- run: phpstan analyse src
792
- ```
793
-
794
- #### Psalm
795
-
796
- Psalm supports error reporting in GitHub Actions with an output format `github`.
797
-
798
- ```yaml
799
- - name: Setup PHP
800
- uses: shivammathur/setup-php@v2
801
- with:
802
- php-version: '7.4'
803
- tools: psalm
804
-
805
- - name: Run Psalm
806
- run: psalm --output-format=github
807
- ```
808
-
809
- #### Tools with checkstyle support
810
-
811
- For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
812
- For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
813
-
814
- > Here is an example with `phpcs`.
815
-
816
- ```yaml
817
- - name: Setup PHP
818
- uses: shivammathur/setup-php@v2
819
- with:
820
- php-version: '7.4'
821
- tools: cs2pr, phpcs
822
-
823
- - name: Run phpcs
824
- run: phpcs -q --report=checkstyle src | cs2pr
825
- ```
826
-
827
- ### Examples
828
-
829
- Examples of using `setup-php` with various PHP Frameworks and Packages.
830
-
831
- |Framework/Package|Runs on|Workflow|
832
- |--- |--- |--- |
833
- |Blackfire|`macOS`, `ubuntu` and `windows`|[blackfire.yml](./examples/blackfire.yml "GitHub Action using Blackfire")|
834
- |Blackfire Player|`macOS`, `ubuntu` and `windows`|[blackfire-player.yml](./examples/blackfire-player.yml "GitHub Action using Blackfire Player")|
835
- |CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")|
836
- |CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")|
837
- |CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")|
838
- |CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")|
839
- |Laravel with `MySQL` and `Redis`|`ubuntu`|[laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis")|
840
- |Laravel with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|
841
- |Laravel without services|`macOS`, `ubuntu` and `windows`|[laravel.yml](./examples/laravel.yml "GitHub Action for Laravel without services")|
842
- |Lumen with `MySQL` and `Redis`|`ubuntu`|[lumen-mysql.yml](./examples/lumen-mysql.yml "GitHub Action for Lumen with MySQL and Redis")|
843
- |Lumen with `PostgreSQL` and `Redis`|`ubuntu`|[lumen-postgres.yml](./examples/lumen-postgres.yml "GitHub Action for Lumen with PostgreSQL and Redis")|
844
- |Lumen without services|`macOS`, `ubuntu` and `windows`|[lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services")|
845
- |Phalcon with `MySQL`|`ubuntu`|[phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL")|
846
- |Phalcon with `PostgreSQL`|`ubuntu`|[phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL")|
847
- |Roots/bedrock|`ubuntu`|[bedrock.yml](./examples/bedrock.yml "GitHub Action for Wordpress Development using @roots/bedrock")|
848
- |Roots/sage|`ubuntu`|[sage.yml](./examples/sage.yml "GitHub Action for Wordpress Development using @roots/sage")|
849
- |Slim Framework|`macOS`, `ubuntu` and `windows`|[slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework")|
850
- |Symfony with `MySQL`|`ubuntu`|[symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL")|
851
- |Symfony with `PostgreSQL`|`ubuntu`|[symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL")|
852
- |Symfony without services|`macOS`, `ubuntu` and `windows`|[symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services")|
853
- |Yii2 Starter Kit with `MySQL`|`ubuntu`|[yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL")|
854
- |Yii2 Starter Kit with `PostgreSQL`|`ubuntu`|[yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL")|
855
- |Zend Framework|`macOS`, `ubuntu` and `windows`|[zend-framework.yml](./examples/zend-framework.yml "GitHub Action for Zend Framework")|
856
-
857
- ## :bookmark: Versioning
858
-
859
- - Use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with the latest minor and patch releases. With `v2` you automatically get the bug fixes, security patches, new features and support for latest PHP releases. For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
860
- - Semantic release versions can also be used. It is recommended to [use dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot "Setup Dependabot with GitHub Actions") with semantic versioning to keep the actions in your workflows up to date.
861
- - Commit SHA can also be used, but are not recommended. They have to be updated with every release manually, without which you will not get any bug fixes, security patches or new features.
862
- - It is highly discouraged to use the `master` branch as version, it might break your workflow after major releases as they have breaking changes.
863
- - If you are using the `v1` tag or a `1.x.y` version, you should [switch to v2](https://github.com/shivammathur/setup-php/wiki/Switch-to-v2 "Guide for switching from setup-php v1 to v2") as `v1` only gets critical bug fixes. Maintenance support for `v1` will be dropped with the last `PHP 8.0` release.
864
-
865
- ## :scroll: License
866
-
867
- - The scripts and documentation in this project are under the [MIT License](LICENSE "License for shivammathur/setup-php").
868
- - This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
869
- - The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License").
870
-
871
- ## :+1: Contributions
872
-
873
- > Contributions are welcome!
874
-
875
- - See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide") before you start.
876
- - If you face any issues or want to suggest a feature/improvement, start a discussion [here](https://github.com/shivammathur/setup-php/discussions "Setup PHP discussions").
877
-
878
- *Contributors of `setup-php` and other related projects*
879
-
880
- <p align="center">
881
- <a href="https://github.com/shivammathur/setup-php/graphs/contributors">
882
- <img src="https://setup-php.com/contributors/?" alt="Contributors of setup-php and related projects" width="100%">
883
- </a>
884
- </p>
885
-
886
- ## :sparkling_heart: Support This Project
887
-
888
- - This project is provided as Free and Open-Source software. We need funds to maintain and do future improvements. Please sponsor setup-php using the below options:
889
- - [Open Collective](https://opencollective.com/setup-php "setup-php Open Collective")
890
- - [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal")
891
- - [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon")
892
- - Please [reach out](mailto:contact@setup-php.com) if you have any questions about sponsoring setup-php.
893
- - Please star the project and share it. If you blog, please share your experience of using this action.
894
-
895
- *`setup-php` is generously supported by*
896
-
897
- <p>
898
- <a href="https://www.jetbrains.com/?from=setup-php">
899
- <img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="106" height="60">
900
- </a>
901
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
902
- <a href="https://blackfire.io/?utm_source=setup-php">
903
- <img src="https://setup-php.com/sponsors//blackfire.svg" alt="Blackfire" width="212" height="60">
904
- </a>
905
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
906
- <a href="https://www.macstadium.com/?source=setup-php">
907
- <img src="https://setup-php.com/sponsors//macstadium.png" alt="Mac Stadium" width="148" height="60">
908
- </a>
909
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
910
- <a href="https://tidelift.com/subscription/pkg/npm-setup-php">
911
- <img src="https://setup-php.com/sponsors//tidelift.png" alt="Tidelift" width="70" height="60">
912
- </a>
913
- </p>
914
-
915
- ## :package: Dependencies
916
-
917
- - [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
918
- - [aaronparker/VcRedist](https://github.com/aaronparker/VcRedist "VcRedist PowerShell package")
919
- - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
920
- - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
921
- - [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions")
922
- - [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases")
923
- - [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS")
924
- - [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
925
- - [shivammathur/icu-intl](https://github.com/shivammathur/icu-intl "icu4c and php-intl builds")
926
- - [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu")
927
- - [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows")
928
- - [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")
929
- - [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to setup PHP5 versions on darwin")
930
- - [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions on ubuntu")
931
-
932
- ## :bookmark_tabs: Further Reading
933
-
934
- - [About GitHub Actions](https://github.com/features/actions "GitHub Actions")
935
- - [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions "GitHub Actions Syntax")
936
- - [Other Awesome Actions](https://github.com/sdras/awesome-actions "List of Awesome GitHub Actions")
1
+ <p align="center">
2
+ <a href="https://github.com/marketplace/actions/setup-php-action" target="_blank">
3
+ <img src="https://repository-images.githubusercontent.com/206578964/e0a18480-dc65-11e9-8dd3-b9ffbf5575fe" alt="Setup PHP in GitHub Actions" width="400">
4
+ </a>
5
+ </p>
6
+
7
+ <h1 align="center">Setup PHP in GitHub Actions</h1>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
11
+ <a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
12
+ <a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
13
+ <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.2-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
14
+ <a href="https://beta.stepsecurity.io/npm/setup-php"><img alt="release verified" src="https://img.shields.io/endpoint?url=https://beta.api.stepsecurity.io/v1/npm/setup-php/badge?q=1"></a>
15
+ </p>
16
+ <p align="center">
17
+ <a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
18
+ <a href="https://twitter.com/setup_php" title="setup-php twitter"><img alt="setup-php twitter" src="https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555"></a>
19
+ <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>
20
+ </p>
21
+
22
+ 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.
23
+
24
+ ## Contents
25
+
26
+ - [OS/Platform Support](#cloud-osplatform-support)
27
+ - [GitHub-Hosted Runners](#github-hosted-runners)
28
+ - [Self-Hosted Runners](#self-hosted-runners)
29
+ - [PHP Support](#tada-php-support)
30
+ - [PHP Extension Support](#heavy_plus_sign-php-extension-support)
31
+ - [Tools Support](#wrench-tools-support)
32
+ - [Coverage Support](#signal_strength-coverage-support)
33
+ - [Xdebug](#xdebug)
34
+ - [PCOV](#pcov)
35
+ - [Disable Coverage](#disable-coverage)
36
+ - [Usage](#memo-usage)
37
+ - [Inputs](#inputs)
38
+ - [Outputs](#outputs)
39
+ - [Flags](#flags)
40
+ - [Basic Setup](#basic-setup)
41
+ - [Matrix Setup](#matrix-setup)
42
+ - [Nightly Build Setup](#nightly-build-setup)
43
+ - [Thread Safe Setup](#thread-safe-setup)
44
+ - [Force Update Setup](#force-update-setup)
45
+ - [Verbose Setup](#verbose-setup)
46
+ - [Multi-Arch Setup](#multi-arch-setup)
47
+ - [Self Hosted Setup](#self-hosted-setup)
48
+ - [Local Testing Setup](#local-testing-setup)
49
+ - [JIT Configuration](#jit-configuration)
50
+ - [Cache Extensions](#cache-extensions)
51
+ - [Cache Composer Dependencies](#cache-composer-dependencies)
52
+ - [Composer GitHub OAuth](#composer-github-oauth)
53
+ - [Inline PHP Scripts](#inline-php-scripts)
54
+ - [Problem Matchers](#problem-matchers)
55
+ - [Examples](#examples)
56
+ - [Versioning](#bookmark-versioning)
57
+ - [License](#scroll-license)
58
+ - [Contributions](#1-contributions)
59
+ - [Support This Project](#sparkling_heart-support-this-project)
60
+ - [Dependencies](#package-dependencies)
61
+ - [Further Reading](#bookmark_tabs-further-reading)
62
+
63
+ ## :cloud: OS/Platform Support
64
+
65
+ Both `GitHub-hosted` and `self-hosted` runners are suppported by `setup-php` on the following OS/Platforms.
66
+
67
+ ### GitHub-Hosted Runners
68
+
69
+ |Virtual environment|YAML workflow label|Pre-installed PHP|
70
+ |--- |--- |--- |
71
+ |Ubuntu 18.04|`ubuntu-18.04`|`PHP 7.1` to `PHP 8.0`|
72
+ |Ubuntu 20.04|`ubuntu-latest` or `ubuntu-20.04`|`PHP 7.4` to `PHP 8.0`|
73
+ |Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 8.0`|
74
+ |Windows Server 2022|`windows-2022`|`PHP 8.0`|
75
+ |macOS Catalina 10.15|`macos-latest` or `macos-10.15`|`PHP 8.0`|
76
+ |macOS Big Sur 11.x|`macos-11`|`PHP 8.0`|
77
+
78
+ ### Self-Hosted Runners
79
+
80
+ |Host OS/Virtual environment|YAML workflow label|
81
+ |--- |--- |
82
+ |Ubuntu 18.04|`self-hosted` or `Linux`|
83
+ |Ubuntu 20.04|`self-hosted` or `Linux`|
84
+ |Ubuntu 21.04|`self-hosted` or `Linux`|
85
+ |Debian 9|`self-hosted` or `Linux`|
86
+ |Debian 10|`self-hosted` or `Linux`|
87
+ |Debian 11|`self-hosted` or `Linux`|
88
+ |Windows 7 and newer|`self-hosted` or `Windows`|
89
+ |Windows Server 2012 R2 and newer|`self-hosted` or `Windows`|
90
+ |macOS Catalina 10.15|`self-hosted` or `macOS`|
91
+ |macOS Big Sur 11.x x86_64/arm64|`self-hosted` or `macOS`|
92
+
93
+ - Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
94
+ - Operating systems based on the above Ubuntu and Debian versions are also supported on a best effort basis.
95
+ - If the requested PHP version is pre-installed, `setup-php` switches to it, otherwise it installs the PHP version.
96
+
97
+ ## :tada: PHP Support
98
+
99
+ On all supported OS/Platforms the following PHP versions are supported as per the runner.
100
+
101
+ - PHP 5.3 to PHP 8.2 on GitHub-hosted runners.
102
+ - PHP 5.6 to PHP 8.2 on self-hosted runners.
103
+
104
+ |PHP Version|Stability|Release Support|Runner Support|
105
+ |--- |--- |--- |--- |
106
+ |`5.3`|`Stable`|`End of life`|`GitHub-hosted`|
107
+ |`5.4`|`Stable`|`End of life`|`GitHub-hosted`|
108
+ |`5.5`|`Stable`|`End of life`|`GitHub-hosted`|
109
+ |`5.6`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
110
+ |`7.0`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
111
+ |`7.1`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
112
+ |`7.2`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
113
+ |`7.3`|`Stable`|`Security fixes only`|`GitHub-hosted`, `self-hosted`|
114
+ |`7.4`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
115
+ |`8.0`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
116
+ |`8.1`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
117
+ |`8.2`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`|
118
+
119
+ **Notes:**
120
+ - Specifying `8.2` in `php-version` input installs a nightly build of `PHP 8.2.0-dev`. See [nightly build setup](#nightly-build-setup) for more information.
121
+ - To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section.
122
+
123
+ ## :heavy_plus_sign: PHP Extension Support
124
+
125
+ PHP extensions can be set up using the `extensions` input. It accepts a `string` in csv-format.
126
+
127
+ - On `Ubuntu`, extensions which are available as a package, available on `PECL` or a git repository can be set up.
128
+
129
+ ```yaml
130
+ - name: Setup PHP with PECL extension
131
+ uses: shivammathur/setup-php@v2
132
+ with:
133
+ php-version: '8.0'
134
+ extensions: imagick, swoole
135
+ ```
136
+
137
+ - On `Windows`, extensions available on `PECL` which have the `DLL` binary can be set up.
138
+
139
+ - On `macOS`, extensions available on `PECL` or a git repository can be set up.
140
+
141
+ - On `Ubuntu` and `macOS` to compile and install an extension from a git repository follow this [guide](https://github.com/shivammathur/setup-php/wiki/Add-extension-from-source "Guide to compile and install PHP extensions in setup-php").
142
+
143
+ - Extensions installed along with PHP if specified are enabled.
144
+
145
+ - 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.
146
+
147
+ ```yaml
148
+ - name: Setup PHP with specific version of PECL extension
149
+ uses: shivammathur/setup-php@v2
150
+ with:
151
+ php-version: '5.4'
152
+ extensions: swoole-1.9.3
153
+ ```
154
+
155
+ - Pre-release versions extensions available on `PECL` can be set up by suffixing the extension's name with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
156
+
157
+ ```yaml
158
+ - name: Setup PHP with pre-release PECL extension
159
+ uses: shivammathur/setup-php@v2
160
+ with:
161
+ php-version: '8.0'
162
+ extensions: xdebug-beta
163
+ ```
164
+
165
+ - Shared extensions can be disabled by prefixing them with a `:`. All extensions depending on the specified extension will also be disabled.
166
+
167
+ ```yaml
168
+ - name: Setup PHP and disable opcache
169
+ uses: shivammathur/setup-php@v2
170
+ with:
171
+ php-version: '8.0'
172
+ extensions: :opcache
173
+ ```
174
+
175
+ - 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.
176
+
177
+ **Note:** This disables all core and third-party shared extensions and thus, can break some tools which need them. So, make sure you add the required extensions after `none` in the `extensions` input.
178
+
179
+ ```yaml
180
+ - name: Setup PHP without any shared extensions except mbstring
181
+ uses: shivammathur/setup-php@v2
182
+ with:
183
+ php-version: '8.0'
184
+ extensions: none, mbstring
185
+ ```
186
+
187
+ - 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. Refer to [`ICU builds`](https://github.com/shivammathur/icu-intl#icu4c-builds) for the specific versions supported.
188
+
189
+ ```yaml
190
+ - name: Setup PHP with intl
191
+ uses: shivammathur/setup-php@v2
192
+ with:
193
+ php-version: '8.0'
194
+ extensions: intl-69.1
195
+ ```
196
+
197
+ - Extensions loaded by default after `setup-php` runs can be found on the [wiki](https://github.com/shivammathur/setup-php/wiki).
198
+
199
+ - These extensions have custom support:
200
+ - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`.
201
+ - `geos` on `Ubuntu` and `macOS`.
202
+ - `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3` and `phalcon4` on all supported OS.
203
+
204
+ - By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
205
+
206
+ ```yaml
207
+ - name: Setup PHP with fail-fast
208
+ uses: shivammathur/setup-php@v2
209
+ with:
210
+ php-version: '8.0'
211
+ extensions: oci8
212
+ env:
213
+ fail-fast: true
214
+ ```
215
+
216
+ ## :wrench: Tools Support
217
+
218
+ These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
219
+
220
+ [`behat`], [`blackfire`], [`blackfire-player`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`prestissimo`], [`protoc`], [`psalm`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
221
+
222
+ ```yaml
223
+ - name: Setup PHP with tools
224
+ uses: shivammathur/setup-php@v2
225
+ with:
226
+ php-version: '8.0'
227
+ tools: php-cs-fixer, phpunit
228
+ ```
229
+
230
+ - 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`.
231
+
232
+ ```yaml
233
+ - name: Setup PHP with tools
234
+ uses: shivammathur/setup-php@v2
235
+ with:
236
+ php-version: '8.0'
237
+ tools: vimeo/psalm
238
+ ```
239
+
240
+ - To set up a particular version of a tool, specify it in the form `tool:version`.
241
+
242
+ Version can be in the following format:
243
+ - Semver. For example `tool:1.2.3` or `tool:1.2.3-beta1`.
244
+ - Major version. For example `tool:1` or `tool:1.x`.
245
+ - Major and minor version. For example `tool:1.2` or `tool:1.2.x`.
246
+
247
+ When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup.
248
+
249
+ Except for major versions of `composer`, For other tools when you specify only the `major` version or the version in `major.minor` format for any tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a [`GitHub` OAuth token](https://github.com/shivammathur/setup-php#composer-github-oauth "Composer GitHub OAuth"). You can do that by setting `COMPOSER_TOKEN` environment variable.
250
+
251
+ ```yaml
252
+ - name: Setup PHP with tools
253
+ uses: shivammathur/setup-php@v2
254
+ with:
255
+ php-version: '8.0'
256
+ tools: php-cs-fixer:3, phpunit:8.5
257
+ env:
258
+ COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
259
+ ```
260
+
261
+ - The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format, Additionally for composer `snapshot` and `preview` can also be specified to set up the respective releases.
262
+
263
+ ```yaml
264
+ - name: Setup PHP with composer v2
265
+ uses: shivammathur/setup-php@v2
266
+ with:
267
+ php-version: '8.0'
268
+ tools: composer:v2
269
+ ```
270
+
271
+ - If you do not use composer in your workflow, you can specify `tools: none` to skip it.
272
+
273
+ ```yaml
274
+ - name: Setup PHP without composer
275
+ uses: shivammathur/setup-php@v2
276
+ with:
277
+ php-version: '8.0'
278
+ tools: none
279
+ ```
280
+
281
+ - Scripts `phpize` and `php-config` are set up with the same version as of the input PHP version.
282
+
283
+ - The latest version of `blackfire` cli is set up when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.
284
+
285
+ - Tools `prestissimo` and `composer-prefetcher` will be skipped unless `composer:v1` is also specified in tools input. It is recommended to drop `prestissimo` and use `composer v2`.
286
+
287
+ - By default, tools which cannot be set up gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
288
+
289
+ ```yaml
290
+ - name: Setup PHP with fail-fast
291
+ uses: shivammathur/setup-php@v2
292
+ with:
293
+ php-version: '8.0'
294
+ tools: deployer
295
+ env:
296
+ fail-fast: true
297
+ ```
298
+
299
+ **Notes**
300
+ - Input `tools` is useful to set up tools which you only use in GitHub Actions, thus keeping your `composer.json` tidy.
301
+ - If you do not want to use all your dev-dependencies in GitHub Actions workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
302
+ - If you have a tool in your `composer.json`, do not set up it with `tools` input as the two instances of the tool might conflict.
303
+
304
+ ## :signal_strength: Coverage Support
305
+
306
+ ### Xdebug
307
+
308
+ Specify `coverage: xdebug` to use `Xdebug` and disable `PCOV`.
309
+ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
310
+
311
+ ```yaml
312
+ - name: Setup PHP with Xdebug
313
+ uses: shivammathur/setup-php@v2
314
+ with:
315
+ php-version: '8.0'
316
+ coverage: xdebug
317
+ ```
318
+
319
+ - The latest version of Xdebug compatible with the PHP version is set up by default.
320
+ - If you need Xdebug 2.x on PHP 7.2, 7.3 or 7.4, you can specify `coverage: xdebug2`.
321
+
322
+ ```yaml
323
+ - name: Setup PHP with Xdebug 2.x
324
+ uses: shivammathur/setup-php@v2
325
+ with:
326
+ php-version: '7.4'
327
+ coverage: xdebug2
328
+ ```
329
+
330
+ ### PCOV
331
+
332
+ Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`.
333
+ Runs on PHP 7.1 and newer PHP versions.
334
+
335
+ - If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
336
+
337
+ ```yaml
338
+ - name: Setup PHP with PCOV
339
+ uses: shivammathur/setup-php@v2
340
+ with:
341
+ php-version: '8.0'
342
+ ini-values: pcov.directory=api #optional, see above for usage.
343
+ coverage: pcov
344
+ ```
345
+
346
+ - PHPUnit 8.x and above supports PCOV out of the box.
347
+ - If you are using PHPUnit 5.x, 6.x or 7.x, you need to set up `pcov/clobber` before executing your tests.
348
+
349
+ ```yaml
350
+ - name: Setup PCOV
351
+ run: |
352
+ composer require pcov/clobber
353
+ vendor/bin/pcov clobber
354
+ ```
355
+
356
+ ### Disable Coverage
357
+
358
+ Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
359
+
360
+ Disable coverage for these reasons:
361
+
362
+ - You are not generating coverage reports while testing.
363
+ - It will disable `Xdebug`, which will have a positive impact on PHP performance.
364
+ - You are using `phpdbg` for running your tests.
365
+ - You are profiling your code using `blackfire`.
366
+ - You are using PHP in JIT mode. Please refer to [JIT configuration](#jit-configuration) section for more details.
367
+
368
+ ```yaml
369
+ - name: Setup PHP with no coverage driver
370
+ uses: shivammathur/setup-php@v2
371
+ with:
372
+ php-version: '8.0'
373
+ coverage: none
374
+ ```
375
+
376
+ ## :memo: Usage
377
+
378
+ ### Inputs
379
+
380
+ > Specify using `with` keyword
381
+
382
+ #### `php-version` (required)
383
+
384
+ - Specify the PHP version you want to set up.
385
+ - Accepts a `string`. For example `'8.0'`.
386
+ - Accepts `latest` to set up the latest stable PHP version.
387
+ - Accepts `nightly` to set up a nightly build from the master branch of PHP.
388
+ - Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
389
+ - See [PHP support](#tada-php-support) for supported PHP versions.
390
+
391
+ #### `extensions` (optional)
392
+
393
+ - Specify the extensions you want to add or disable.
394
+ - Accepts a `string` in csv-format. For example `mbstring, :opcache`.
395
+ - Accepts `none` to disable all shared extensions.
396
+ - Shared extensions prefixed with `:` are disabled.
397
+ - See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info.
398
+
399
+ #### `ini-values` (optional)
400
+
401
+ - Specify the values you want to add to `php.ini`.
402
+ - Accepts a `string` in csv-format. For example `post_max_size=256M, max_execution_time=180`.
403
+ - Accepts ini values with commas if wrapped in quotes. For example `xdebug.mode="develop,coverage"`.
404
+
405
+ #### `coverage` (optional)
406
+
407
+ - Specify the code-coverage driver you want to set up.
408
+ - Accepts `xdebug`, `pcov` or `none`.
409
+ - See [coverage support](#signal_strength-coverage-support) for more info.
410
+
411
+ #### `tools` (optional)
412
+
413
+ - Specify the tools you want to set up.
414
+ - Accepts a `string` in csv-format. For example: `phpunit, phpcs`
415
+ - See [tools Support](#wrench-tools-support) for tools supported.
416
+
417
+ ### Outputs
418
+
419
+ #### `php-version`
420
+
421
+ To use outputs, give the `setup-php` step an `id`, you can use the same to get the outputs in a later step.
422
+
423
+ - Provides the PHP version in semver format.
424
+
425
+ ```yaml
426
+ - name: Setup PHP
427
+ id: setup-php
428
+ uses: shivammathur/setup-php@v2
429
+ with:
430
+ php-version: '8.0'
431
+
432
+ - name: Print PHP version
433
+ run: echo ${{ steps.setup-php.outputs.php-version }}
434
+ ```
435
+
436
+ ### Flags
437
+
438
+ > Specify using `env` keyword
439
+
440
+ #### `fail-fast` (optional)
441
+
442
+ - Specify to mark the workflow as failed if an extension or tool fails to set up.
443
+ - This changes the default mode from graceful warnings to fail-fast.
444
+ - By default, it is set to `false`.
445
+ - Accepts `true` and `false`.
446
+
447
+ #### `phpts` (optional)
448
+
449
+ - Specify to set up thread-safe version of PHP on Windows.
450
+ - Accepts `ts` and `nts`.
451
+ - By default, it is set to `nts`.
452
+ - See [thread safe setup](#thread-safe-setup) for more info.
453
+
454
+ #### `update` (optional)
455
+
456
+ - Specify to update PHP on the runner to the latest patch version.
457
+ - Accepts `true` and `false`.
458
+ - By default, it is set to `false`.
459
+ - See [force update setup](#force-update-setup) for more info.
460
+
461
+ See below for more info.
462
+
463
+ ### Basic Setup
464
+
465
+ > Setup a particular PHP version.
466
+
467
+ ```yaml
468
+ steps:
469
+ - name: Setup PHP
470
+ uses: shivammathur/setup-php@v2
471
+ with:
472
+ php-version: '8.0'
473
+ extensions: mbstring, intl
474
+ ini-values: post_max_size=256M, max_execution_time=180
475
+ coverage: xdebug
476
+ tools: php-cs-fixer, phpunit
477
+ ```
478
+
479
+ ### Matrix Setup
480
+
481
+ > Setup multiple PHP versions on multiple operating systems.
482
+
483
+ ```yaml
484
+ jobs:
485
+ run:
486
+ runs-on: ${{ matrix.operating-system }}
487
+ strategy:
488
+ matrix:
489
+ operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
490
+ php-versions: ['7.3', '7.4', '8.0']
491
+ phpunit-versions: ['latest']
492
+ include:
493
+ - operating-system: 'ubuntu-latest'
494
+ php-versions: '7.2'
495
+ phpunit-versions: '8.5.21'
496
+ steps:
497
+ - name: Setup PHP
498
+ uses: shivammathur/setup-php@v2
499
+ with:
500
+ php-version: ${{ matrix.php-versions }}
501
+ extensions: mbstring, intl
502
+ ini-values: post_max_size=256M, max_execution_time=180
503
+ coverage: xdebug
504
+ tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
505
+ ```
506
+
507
+ ### Nightly Build Setup
508
+
509
+ > Setup a nightly build of `PHP 8.2`.
510
+
511
+ - This version is currently in development.
512
+ - Some user space extensions might not support this version currently.
513
+
514
+ ```yaml
515
+ steps:
516
+ - name: Setup nightly PHP
517
+ uses: shivammathur/setup-php@v2
518
+ with:
519
+ php-version: '8.2'
520
+ extensions: mbstring
521
+ ini-values: post_max_size=256M, max_execution_time=180
522
+ coverage: xdebug
523
+ tools: php-cs-fixer, phpunit
524
+ ```
525
+
526
+ ### Thread Safe Setup
527
+
528
+ > Setup `TS` or `NTS` PHP on `Windows`.
529
+
530
+ - `NTS` versions are set up by default.
531
+ - On `Ubuntu` and `macOS` only `NTS` versions are supported.
532
+ - On `Windows` both `TS` and `NTS` versions are supported.
533
+
534
+ ```yaml
535
+ jobs:
536
+ run:
537
+ runs-on: windows-latest
538
+ name: Setup PHP TS on Windows
539
+ steps:
540
+ - name: Setup PHP
541
+ uses: shivammathur/setup-php@v2
542
+ with:
543
+ php-version: '8.0'
544
+ env:
545
+ phpts: ts # specify ts or nts
546
+ ```
547
+
548
+ ### Force Update Setup
549
+
550
+ > Update to the latest patch of PHP versions.
551
+
552
+ - Pre-installed PHP versions on the GitHub Actions images are not updated to their latest patch release by default.
553
+ - You can specify the `update` environment variable to `true` for updating to the latest release.
554
+
555
+ ```yaml
556
+ - name: Setup PHP with latest versions
557
+ uses: shivammathur/setup-php@v2
558
+ with:
559
+ php-version: '8.0'
560
+ env:
561
+ update: true # specify true or false
562
+ ```
563
+
564
+ ### Verbose Setup
565
+
566
+ > Debug your workflow
567
+
568
+ To debug any issues, you can use the `verbose` tag instead of `v2`.
569
+
570
+ ```yaml
571
+ - name: Setup PHP with logs
572
+ uses: shivammathur/setup-php@verbose
573
+ with:
574
+ php-version: '8.0'
575
+ ```
576
+
577
+ ### Multi-Arch Setup
578
+
579
+ > Setup PHP on multiple architecture on Ubuntu GitHub Runners.
580
+
581
+ - `PHP 5.6` to `PHP 8.0` are supported by `setup-php` on multiple architecture on `Ubuntu`.
582
+ - For this, you can use `shivammathur/node` images as containers. These have compatible `Nodejs` installed for JavaScript based GitHub Actions.
583
+ - Currently, for `ARM` based setup, you will need [self-hosted runners](#self-hosted-setup).
584
+
585
+ ```yaml
586
+ jobs:
587
+ run:
588
+ runs-on: ubuntu-latest
589
+ container: shivammathur/node:latest-${{ matrix.arch }}
590
+ strategy:
591
+ matrix:
592
+ arch: ["amd64", "i386"]
593
+ steps:
594
+ - name: Install PHP
595
+ uses: shivammathur/setup-php@v2
596
+ with:
597
+ php-version: '8.0'
598
+ ```
599
+
600
+ ### Self Hosted Setup
601
+
602
+ > Setup PHP on a self-hosted runner.
603
+
604
+ - To set up a containerised self-hosted runner, refer to the following guides as per your base operating system.
605
+ - [Linux](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Linux)
606
+ - [Windows](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Windows)
607
+
608
+ - To set up the runner directly on the host OS or in a virtual machine, follow this [requirements guide](https://github.com/shivammathur/setup-php/wiki/Requirements-for-self-hosted-runners "Requirements guide for self-hosted runner to run setup-php") before setting up the self-hosted runner.
609
+ - If your workflow uses [service containers](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then set up the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container.
610
+
611
+ Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail.
612
+
613
+ ```yaml
614
+ jobs:
615
+ run:
616
+ runs-on: self-hosted
617
+ strategy:
618
+ matrix:
619
+ php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
620
+ name: PHP ${{ matrix.php-versions }}
621
+ steps:
622
+ - name: Setup PHP
623
+ uses: shivammathur/setup-php@v2
624
+ with:
625
+ php-version: ${{ matrix.php-versions }}
626
+ env:
627
+ runner: self-hosted # Specify the runner.
628
+ ```
629
+
630
+ **Notes**
631
+ - Do not set up multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other.
632
+ - Do not set up self-hosted runners on the side on your development environment or your production server.
633
+ - Avoid using the same labels for your `self-hosted` runners which are used by `GitHub-hosted` runners.
634
+
635
+ ### Local Testing Setup
636
+
637
+ > Test your `Ubuntu` workflow locally using [`nektos/act`](https://github.com/nektos/act "Project to test GitHub Actions locally").
638
+
639
+ ```yaml
640
+ jobs:
641
+ run:
642
+ runs-on: ubuntu-latest
643
+ steps:
644
+ - name: Setup PHP
645
+ uses: shivammathur/setup-php@v2
646
+ with:
647
+ php-version: '8.0'
648
+ ```
649
+
650
+ Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker images.
651
+
652
+ Choose the image tag which matches the `runs-on` property in your workflow. For example, if you are using `ubuntu-20.04` in your workflow, run `act -P ubuntu-20.04=shivammathur/node:20.04`.
653
+
654
+ ```bash
655
+ # For runs-on: ubuntu-latest
656
+ act -P ubuntu-latest=shivammathur/node:latest
657
+
658
+ # For runs-on: ubuntu-20.04
659
+ act -P ubuntu-20.04=shivammathur/node:2004
660
+
661
+ # For runs-on: ubuntu-18.04
662
+ act -P ubuntu-18.04=shivammathur/node:1804
663
+ ```
664
+
665
+ ### JIT Configuration
666
+
667
+ > Enable Just-in-time(JIT) on PHP 8.0 and above.
668
+
669
+ - To enable JIT, enable `opcache` in cli mode by setting `opcache.enable_cli=1`.
670
+ - JIT conflicts with `Xdebug`, `PCOV`, and other extensions which override `zend_execute_ex` function, so set `coverage: none` and disable any such extension if added.
671
+ - By default, `opcache.jit=1235` and `opcache.jit_buffer_size=256M` are set which can be changed using `ini-values` input.
672
+ - For detailed information about JIT related directives refer to the [`official PHP documentation`](https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit "opcache.jit documentation").
673
+
674
+ For example to enable JIT in `tracing` mode with buffer size of `64 MB`.
675
+
676
+ ```yaml
677
+ - name: Setup PHP with JIT in tracing mode
678
+ uses: shivammathur/setup-php@v2
679
+ with:
680
+ php-version: '8.0'
681
+ coverage: none
682
+ ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
683
+ ```
684
+
685
+ ### Cache Extensions
686
+
687
+ You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to set up when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
688
+ Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details.
689
+
690
+ ### Cache Composer Dependencies
691
+
692
+ If your project uses composer, you can persist the composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
693
+
694
+ ```yaml
695
+ - name: Get composer cache directory
696
+ id: composer-cache
697
+ run: echo "::set-output name=dir::$(composer config cache-files-dir)"
698
+
699
+ - name: Cache dependencies
700
+ uses: actions/cache@v2
701
+ with:
702
+ path: ${{ steps.composer-cache.outputs.dir }}
703
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
704
+ restore-keys: ${{ runner.os }}-composer-
705
+
706
+ - name: Install dependencies
707
+ run: composer install --prefer-dist
708
+ ```
709
+
710
+ **Notes**
711
+ - Please do not cache `vendor` directory using `action/cache` as that will have side effects.
712
+ - If you do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
713
+ ```yaml
714
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
715
+ ```
716
+
717
+ - If you support a range of `composer` dependencies and use `prefer-lowest` and `prefer-stable` options, you can store them in your matrix and add them to the keys.
718
+ ```yaml
719
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.prefer }}-
720
+ restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
721
+ ```
722
+
723
+ ### Composer GitHub OAuth
724
+
725
+ If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in `major.minor` format, you can hit the rate limit. To avoid this you can specify an `OAuth` token by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
726
+
727
+ ```yaml
728
+ - name: Setup PHP
729
+ uses: shivammathur/setup-php@v2
730
+ with:
731
+ php-version: '8.0'
732
+ env:
733
+ COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
734
+ ```
735
+
736
+ ### Inline PHP Scripts
737
+
738
+ If you have to run multiple lines of PHP code in your workflow, you can do that easily without saving it to a file.
739
+
740
+ Put the code in the run property of a step and specify the shell as `php {0}`.
741
+
742
+ ```yaml
743
+ - name: Setup PHP
744
+ uses: shivammathur/setup-php@v2
745
+ with:
746
+ php-version: '8.0'
747
+
748
+ - name: Run PHP code
749
+ shell: php {0}
750
+ run: |
751
+ <?php
752
+ $welcome = "Hello, world";
753
+ echo $welcome;
754
+ ```
755
+
756
+ ### Problem Matchers
757
+
758
+ Problem matchers are `json` configurations which identify errors and warnings in your logs and surface them prominently in the GitHub Actions UI by highlighting them and creating code annotations.
759
+
760
+ #### PHP
761
+
762
+ Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
763
+
764
+ ```yaml
765
+ - name: Setup problem matchers for PHP
766
+ run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
767
+ ```
768
+
769
+ #### PHPUnit
770
+
771
+ Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
772
+
773
+ ```yaml
774
+ - name: Setup problem matchers for PHPUnit
775
+ run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
776
+ ```
777
+
778
+ #### PHPStan
779
+
780
+ PHPStan supports error reporting in GitHub Actions, so it does not require problem matchers.
781
+
782
+ ```yaml
783
+ - name: Setup PHP
784
+ uses: shivammathur/setup-php@v2
785
+ with:
786
+ php-version: '8.0'
787
+ tools: phpstan
788
+
789
+ - name: Run PHPStan
790
+ run: phpstan analyse src
791
+ ```
792
+
793
+ #### Psalm
794
+
795
+ Psalm supports error reporting in GitHub Actions with an output format `github`.
796
+
797
+ ```yaml
798
+ - name: Setup PHP
799
+ uses: shivammathur/setup-php@v2
800
+ with:
801
+ php-version: '8.0'
802
+ tools: psalm
803
+
804
+ - name: Run Psalm
805
+ run: psalm --output-format=github
806
+ ```
807
+
808
+ #### Tools with checkstyle support
809
+
810
+ For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
811
+ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
812
+
813
+ > Here is an example with `phpcs`.
814
+
815
+ ```yaml
816
+ - name: Setup PHP
817
+ uses: shivammathur/setup-php@v2
818
+ with:
819
+ php-version: '8.0'
820
+ tools: cs2pr, phpcs
821
+
822
+ - name: Run phpcs
823
+ run: phpcs -q --report=checkstyle src | cs2pr
824
+ ```
825
+
826
+ ### Examples
827
+
828
+ Examples of using `setup-php` with various PHP Frameworks and Packages.
829
+
830
+ |Framework/Package|Runs on|Workflow|
831
+ |--- |--- |--- |
832
+ |Blackfire|`macOS`, `ubuntu` and `windows`|[blackfire.yml](./examples/blackfire.yml "GitHub Action using Blackfire")|
833
+ |Blackfire Player|`macOS`, `ubuntu` and `windows`|[blackfire-player.yml](./examples/blackfire-player.yml "GitHub Action using Blackfire Player")|
834
+ |CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")|
835
+ |CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")|
836
+ |CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")|
837
+ |CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")|
838
+ |Laravel with `MySQL` and `Redis`|`ubuntu`|[laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis")|
839
+ |Laravel with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|
840
+ |Laravel without services|`macOS`, `ubuntu` and `windows`|[laravel.yml](./examples/laravel.yml "GitHub Action for Laravel without services")|
841
+ |Lumen with `MySQL` and `Redis`|`ubuntu`|[lumen-mysql.yml](./examples/lumen-mysql.yml "GitHub Action for Lumen with MySQL and Redis")|
842
+ |Lumen with `PostgreSQL` and `Redis`|`ubuntu`|[lumen-postgres.yml](./examples/lumen-postgres.yml "GitHub Action for Lumen with PostgreSQL and Redis")|
843
+ |Lumen without services|`macOS`, `ubuntu` and `windows`|[lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services")|
844
+ |Phalcon with `MySQL`|`ubuntu`|[phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL")|
845
+ |Phalcon with `PostgreSQL`|`ubuntu`|[phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL")|
846
+ |Roots/bedrock|`ubuntu`|[bedrock.yml](./examples/bedrock.yml "GitHub Action for Wordpress Development using @roots/bedrock")|
847
+ |Roots/sage|`ubuntu`|[sage.yml](./examples/sage.yml "GitHub Action for Wordpress Development using @roots/sage")|
848
+ |Slim Framework|`macOS`, `ubuntu` and `windows`|[slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework")|
849
+ |Symfony with `MySQL`|`ubuntu`|[symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL")|
850
+ |Symfony with `PostgreSQL`|`ubuntu`|[symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL")|
851
+ |Symfony without services|`macOS`, `ubuntu` and `windows`|[symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services")|
852
+ |Yii2 Starter Kit with `MySQL`|`ubuntu`|[yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL")|
853
+ |Yii2 Starter Kit with `PostgreSQL`|`ubuntu`|[yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL")|
854
+ |Zend Framework|`macOS`, `ubuntu` and `windows`|[zend-framework.yml](./examples/zend-framework.yml "GitHub Action for Zend Framework")|
855
+
856
+ ## :bookmark: Versioning
857
+
858
+ - Use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with the latest minor and patch releases. With `v2` you automatically get the bug fixes, security patches, new features and support for latest PHP releases. For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
859
+ - Semantic release versions can also be used. It is recommended to [use dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot "Setup Dependabot with GitHub Actions") with semantic versioning to keep the actions in your workflows up to date.
860
+ - Commit SHA can also be used, but are not recommended. They have to be updated with every release manually, without which you will not get any bug fixes, security patches or new features.
861
+ - It is highly discouraged to use the `master` branch as version, it might break your workflow after major releases as they have breaking changes.
862
+ - If you are using the `v1` tag or a `1.x.y` version, you should [switch to v2](https://github.com/shivammathur/setup-php/wiki/Switch-to-v2 "Guide for switching from setup-php v1 to v2") as `v1` only gets critical bug fixes. Maintenance support for `v1` will be dropped with the last `PHP 8.0` release.
863
+
864
+ ## :scroll: License
865
+
866
+ - The scripts and documentation in this project are under the [MIT License](LICENSE "License for shivammathur/setup-php").
867
+ - This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
868
+ - The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License").
869
+
870
+ ## :+1: Contributions
871
+
872
+ > Contributions are welcome!
873
+
874
+ - See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide") before you start.
875
+ - If you face any issues or want to suggest a feature/improvement, start a discussion [here](https://github.com/shivammathur/setup-php/discussions "Setup PHP discussions").
876
+
877
+ *Contributors of `setup-php` and other related projects*
878
+
879
+ <p align="center">
880
+ <a href="https://github.com/shivammathur/setup-php/graphs/contributors">
881
+ <img src="https://setup-php.com/contributors/?" alt="Contributors of setup-php and related projects" width="100%">
882
+ </a>
883
+ </p>
884
+
885
+ ## :sparkling_heart: Support This Project
886
+
887
+ - Please star the project and share it. If you blog, please share your experience of using this action.
888
+ - Please sponsor setup-php using [GitHub sponsors](https://github.com/sponsors/shivammathur).
889
+ - Please [reach out](mailto:contact@setup-php.com) if you have any questions about sponsoring setup-php.
890
+
891
+ [![Sponsor shivammathur](https://img.shields.io/badge/-Sponsor-fafbfc?logo=GitHub%20Sponsors)](https://github.com/sponsors/shivammathur)
892
+
893
+ ### Corporate Sponsors
894
+
895
+ <p align="center">
896
+ <a href="https://setup-php.com/sponsors-corp/?">
897
+ <img src="https://setup-php.com/sponsors-corp/?" alt="Corporate sponsors of setup-php and related projects" width="100%">
898
+ </a>
899
+ </p>
900
+
901
+ ### Individual Sponsors
902
+
903
+ <p align="center">
904
+ <a href="https://setup-php.com/sponsors/?">
905
+ <img src="https://setup-php.com/sponsors/?" alt="Individual sponsors of setup-php and related projects" width="100%">
906
+ </a>
907
+ </p>
908
+
909
+ ## :package: Dependencies
910
+
911
+ - [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
912
+ - [aaronparker/VcRedist](https://github.com/aaronparker/VcRedist "VcRedist PowerShell package")
913
+ - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
914
+ - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
915
+ - [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions")
916
+ - [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases")
917
+ - [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS")
918
+ - [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
919
+ - [shivammathur/icu-intl](https://github.com/shivammathur/icu-intl "icu4c and php-intl builds")
920
+ - [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu")
921
+ - [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows")
922
+ - [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")
923
+ - [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to set up PHP5 versions on darwin")
924
+ - [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to set up PHP5 versions on ubuntu")
925
+
926
+ ## :bookmark_tabs: Further Reading
927
+
928
+ - [About GitHub Actions](https://github.com/features/actions "GitHub Actions")
929
+ - [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions "GitHub Actions Syntax")
930
+ - [Other Awesome Actions](https://github.com/sdras/awesome-actions "List of Awesome GitHub Actions")
931
+
932
+
933
+ <!-- Links to tools -->
934
+ [`behat`]: https://docs.behat.org/en/latest/
935
+ [`blackfire`]: https://blackfire.io/docs/php/index
936
+ [`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
937
+ [`codeception`]: https://codeception.com/
938
+ [`composer`]: https://getcomposer.org/
939
+ [`composer-normalize`]: https://github.com/ergebnis/composer-normalize
940
+ [`composer-prefetcher`]: https://github.com/narrowspark/automatic-composer-prefetcher
941
+ [`composer-require-checker`]: https://github.com/maglnet/ComposerRequireChecker
942
+ [`composer-unused`]: https://github.com/composer-unused/composer-unused
943
+ [`cs2pr`]: https://github.com/staabm/annotate-pull-request-from-checkstyle
944
+ [`deployer`]: https://deployer.org/
945
+ [`flex`]: https://flex.symfony.com/
946
+ [`grpc_php_plugin`]: https://grpc.io/
947
+ [`infection`]: https://infection.github.io/
948
+ [`parallel-lint`]: https://github.com/php-parallel-lint/PHP-Parallel-Lint
949
+ [`pecl`]: https://pecl.php.net/
950
+ [`phan`]: https://github.com/phan/phan/wiki
951
+ [`phing`]: https://www.phing.info/
952
+ [`phinx`]: https://phinx.org/
953
+ [`phive`]: https://phar.io/
954
+ [`php-config`]: https://www.php.net/manual/en/install.pecl.php-config.php
955
+ [`php-cs-fixer`]: https://cs.symfony.com/
956
+ [`phpcbf`]: https://github.com/squizlabs/php_codesniffer
957
+ [`phpcpd`]: https://github.com/sebastianbergmann/phpcpd
958
+ [`phpcs`]: https://github.com/squizlabs/php_codesniffer
959
+ [`phpdoc`]: https://phpdoc.org/
960
+ [`phpDocumentor`]: https://phpdoc.org/
961
+ [`phpize`]: https://www.php.net/manual/en/install.pecl.phpize.php
962
+ [`phplint`]: https://github.com/overtrue/phplint
963
+ [`phpmd`]: https://phpmd.org/
964
+ [`phpspec`]: https://www.phpspec.net/
965
+ [`phpstan`]: https://phpstan.org/
966
+ [`phpunit`]: https://phpunit.de/
967
+ [`phpunit-bridge`]: https://symfony.com/doc/current/components/phpunit_bridge.html
968
+ [`phpunit-polyfills`]: https://github.com/Yoast/PHPUnit-Polyfills
969
+ [`prestissimo`]: https://github.com/hirak/prestissimo
970
+ [`protoc`]: https://developers.google.com/protocol-buffers/
971
+ [`psalm`]: https://psalm.dev/
972
+ [`symfony`]: https://symfony.com/download
973
+ [`symfony-cli`]: https://symfony.com/download
974
+ [`vapor`]: https://docs.vapor.build/
975
+ [`vapor-cli`]: https://docs.vapor.build/
976
+ [`wp`]: https://wp-cli.org/
977
+ [`wp-cli`]: https://wp-cli.org/