You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 setup 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.
@@ -100,11 +103,12 @@ Both `GitHub-hosted` runners and `self-hosted` runners are supported on the foll
100
103
- On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input.
101
104
102
105
```yaml
103
-
uses: shivammathur/setup-php@v2
104
-
with:
105
-
php-version: '7.4'
106
-
tools: pecl
107
-
extensions: swoole
106
+
- name: Setup PHP with pecl extension
107
+
uses: shivammathur/setup-php@v2
108
+
with:
109
+
php-version: '7.4'
110
+
tools: pecl
111
+
extensions: swoole
108
112
```
109
113
110
114
- On `windows` PECL extensions which have the `DLL` binary can be installed.
@@ -116,30 +120,33 @@ with:
116
120
- Specific versions of PECL extensions can be installed by suffixing the version. This is useful for installing old versions of extensions which support end of life PHP versions.
117
121
118
122
```yaml
119
-
uses: shivammathur/setup-php@v2
120
-
with:
121
-
php-version: '5.4'
122
-
tools: pecl
123
-
extensions: swoole-1.9.3
123
+
- name: Setup PHP with specific version of PECL extension
124
+
uses: shivammathur/setup-php@v2
125
+
with:
126
+
php-version: '5.4'
127
+
tools: pecl
128
+
extensions: swoole-1.9.3
124
129
```
125
130
126
131
- Pre-release versions of PECL extensions can be setup by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
127
132
128
133
```yaml
129
-
uses: shivammathur/setup-php@v2
130
-
with:
131
-
php-version: '7.4'
132
-
tools: pecl
133
-
extensions: xdebug-beta
134
+
- name: Setup PHP with pre-release PECL extension
135
+
uses: shivammathur/setup-php@v2
136
+
with:
137
+
php-version: '7.4'
138
+
tools: pecl
139
+
extensions: xdebug-beta
134
140
```
135
141
136
142
- Shared extensions can be removed by prefixing them with a `:`.
137
143
138
144
```yaml
139
-
uses: shivammathur/setup-php@v2
140
-
with:
141
-
php-version: '7.4'
142
-
extensions: :opcache
145
+
- name: Setup PHP and remove shared extension
146
+
uses: shivammathur/setup-php@v2
147
+
with:
148
+
php-version: '7.4'
149
+
extensions: :opcache
143
150
```
144
151
145
152
- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
@@ -153,33 +160,39 @@ These tools can be setup globally using the `tools` input.
To setup a particular version of a tool, specify it in the form `tool:version`.
163
171
Latest stable version of `composer` is setup by default. You can setup the required version by specifying `v1`, `v2`, `snapshot` or `preview` as version.
164
172
165
173
```yaml
166
-
uses: shivammathur/setup-php@v2
167
-
with:
168
-
php-version: '7.4'
169
-
tools: composer:v2
174
+
- name: Setup PHP with composer v2
175
+
uses: shivammathur/setup-php@v2
176
+
with:
177
+
php-version: '7.4'
178
+
tools: composer:v2
170
179
```
171
180
172
-
Version for other tools should be in `semver` format and a valid release of the tool.
181
+
Latest versions of both agent `blackfire-agent` and client `blackfire` are setup 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.
182
+
183
+
Version for other tools should be in `semver` format and a valid release of the tool.
184
+
This is useful for installing tools for older versions of PHP.
185
+
For example to setup `PHPUnit` on `PHP 7.2`.
173
186
174
187
```yaml
175
-
uses: shivammathur/setup-php@v2
176
-
with:
177
-
php-version: '7.4'
178
-
tools: php-cs-fixer:2.16.2, phpunit:8.5.1
188
+
- name: Setup PHP with tools
189
+
uses: shivammathur/setup-php@v2
190
+
with:
191
+
php-version: '7.2'
192
+
tools: phpunit:8.5.8
179
193
```
180
194
181
195
**Notes**
182
-
- Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input.
183
196
- If you have a tool in your `composer.json`, do not setup it globally using this action as the two instances of the tool might conflict.
184
197
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
185
198
@@ -191,10 +204,11 @@ Specify `coverage: xdebug` to use `Xdebug`.
191
204
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
192
205
193
206
```yaml
194
-
uses: shivammathur/setup-php@v2
195
-
with:
196
-
php-version: '7.4'
197
-
coverage: xdebug
207
+
- name: Setup PHP with Xdebug
208
+
uses: shivammathur/setup-php@v2
209
+
with:
210
+
php-version: '7.4'
211
+
coverage: xdebug
198
212
```
199
213
200
214
### PCOV
@@ -205,11 +219,23 @@ Tests with `PCOV` run much faster than with `Xdebug`.
205
219
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
206
220
207
221
```yaml
208
-
uses: shivammathur/setup-php@v2
209
-
with:
210
-
php-version: '7.4'
211
-
ini-values: pcov.directory=api #optional, see above for usage.
212
-
coverage: pcov
222
+
- name: Setup PHP with PCOV
223
+
uses: shivammathur/setup-php@v2
224
+
with:
225
+
php-version: '7.4'
226
+
ini-values: pcov.directory=api #optional, see above for usage.
227
+
coverage: pcov
228
+
```
229
+
230
+
`PHPUnit`8 and above supports `PCOV` out of the box.
231
+
If you are using `PHPUnit` 5, 6 or 7, you will need `krakjoe/pcov-clobber`.
232
+
Before executing your tests add the following step.
233
+
234
+
```yaml
235
+
- name: Setup PCOV
236
+
run: |
237
+
composer require pcov/clobber
238
+
vendor/bin/pcov clobber
213
239
```
214
240
215
241
### Disable Coverage
@@ -223,10 +249,11 @@ Consider disabling the coverage using this PHP action for these reasons.
223
249
- You are profiling your code using `blackfire`.
224
250
225
251
```yaml
226
-
uses: shivammathur/setup-php@v2
227
-
with:
228
-
php-version: '7.4'
229
-
coverage: none
252
+
- name: Setup PHP with no coverage driver
253
+
uses: shivammathur/setup-php@v2
254
+
with:
255
+
php-version: '7.4'
256
+
coverage: none
230
257
```
231
258
232
259
## :memo: Usage
@@ -326,7 +353,7 @@ steps:
326
353
- name: Checkout
327
354
uses: actions/checkout@v2
328
355
329
-
- name: Setup PHP
356
+
- name: Setup nightly PHP
330
357
uses: shivammathur/setup-php@v2
331
358
with:
332
359
php-version: '8.0'
@@ -438,7 +465,7 @@ jobs:
438
465
- You can specify the `update` environment variable to `true` to force update to the latest release.
439
466
440
467
```yaml
441
-
- name: Setup PHP
468
+
- name: Setup PHP with latest versions
442
469
uses: shivammathur/setup-php@v2
443
470
with:
444
471
php-version: '7.4'
@@ -453,7 +480,7 @@ jobs:
453
480
To debug any issues, you can use the `verbose` tag instead of `v2`.
0 commit comments