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
This guide covers build environment and configuration topics specific to PHP projects. Please make sure to read our [Getting Started](/user/getting-started/) and [general build configuration](/user/customizing-the-build/) guides first.
10
+
<asidemarkdown="block"class="ataglance">
10
11
11
-
PHP builds are not available on the OS X environment.
This guide covers build environment and configuration topics specific to PHP
37
+
projects. Please make sure to read our [Getting Started](/user/getting-started/)
38
+
and [build configuration](/user/customizing-the-build/) guides first.
39
+
40
+
PHP builds are not available on the OS X environment.
14
41
15
42
## Choosing PHP versions to test against
16
43
17
-
PHP VM images on travis-ci.org provide several PHP versions including XDebug as well as PHPUnit. Travis CI uses [phpenv](https://github.com/CHH/phpenv) to manage the different PHP versions installed on the VM.
44
+
Travis CI provides several PHP versions, all of which include XDebug and
45
+
PHPUnit. Travis CI uses [phpenv](https://github.com/CHH/phpenv) to manage the
46
+
different PHP versions installed on the virtual machines.
18
47
19
-
A minimalistic`.travis.yml` file would look like this:
48
+
An example`.travis.yml` file that tests various PHP versions:
20
49
21
50
```yaml
22
51
language: php
23
52
php:
24
53
- '5.4'
25
-
- '5.5'
26
54
- '5.6'
27
55
- '7.0'
28
-
- '7.1'
29
56
- hhvm # on Trusty only
30
57
- nightly
31
58
```
32
59
{: data-file=".travis.yml"}
33
60
34
-
The previous example uses `phpunit`, the default build script, to build against the following list of PHP versions:
61
+
`X.Y`versions are aliases for recent `X.Y.Z` releases pre-installed on the build images.
62
+
For exact versions used in your build, consult "Build system information" in the build log.
35
63
36
-
- 5.4.x
37
-
- 5.5.x
38
-
- 5.6.x
39
-
- 7.0.x
40
-
- 7.1.x
41
-
- hhvm # on Trusty only
42
-
- nightly
64
+
These may not be the most recent releases. If you need to ensure the use of most recent releases, do provide the third number; e.g.,
43
65
44
-
which are specified using aliases for the "most recent x.y.z release" provided on Travis CI of any given line. For a full listing of the supported versions see [About Travis CI Environment](/user/reference/precise/).
66
+
```yaml
67
+
language: php
68
+
php:
69
+
- 7.1.9
70
+
```
71
+
{: data-file=".travis.yml"}
45
72
46
-
You can see an [example of version number aliases](https://github.com/travis-ci/travis-ci-php-example/blob/master/.travis.yml) on github. For precise versions used in your build, consult "Build system information" in the build log.
73
+
### PHP 5.2(.x) and 5.3(.x) support is available on Precise only
74
+
75
+
We do not suppport these versions on Trusty.
76
+
If you need to test them, please use Precise.
77
+
See [this page](/user/reference/trusty#PHP-images) for more information.
47
78
48
-
> Specifying exact versions like 5.3.8 is discouraged as it may break your build when we update PHP versions on Travis CI. PHP version *5.5.9* is supported, however, because it's the version of PHP that is shipped with Ubuntu 14.04 LTS.
49
79
50
80
### HHVM versions
51
81
52
-
Travis CI can test your PHP applications with HHVM on Ubuntu Trusty.
82
+
Travis CI can test your PHP applications with HHVM on Ubuntu Trusty:
53
83
54
-
Without specifying further, the latest version of HHVM available for the Ubuntu Trusty.
84
+
```yaml
85
+
php
86
+
- hhvm-3.18
87
+
- hhvm-nightly
88
+
```
89
+
90
+
### Nightly builds
55
91
56
-
#### HHVM versions on Trusty
92
+
Travis CI can test your PHP applications with a nightly
93
+
[PHP](https://github.com/php/php-src/) build, which includes PHPUnit and
94
+
Composer:
57
95
58
96
```yaml
59
97
language: php
60
-
sudo: required
61
-
dist: trusty
62
-
group: edge
98
+
63
99
php:
64
-
- hhvm-3.3
65
-
- hhvm-3.6
66
-
- hhvm-3.9
67
-
- hhvm-3.12
68
-
- hhvm-3.15
69
-
- hhvm-3.18
70
-
- hhvm-nightly
100
+
- nightly
71
101
```
72
102
{: data-file=".travis.yml"}
73
103
74
-
## Default Test Script (PHPUnit)
104
+
## Default Build Script
75
105
76
-
The default test script is PHPUnit. It comes packaged with PHP, but you can also
106
+
The default build script is PHPUnit. It comes packaged with PHP, but you can also
77
107
install a specific version in a custom location. If you do install it
78
108
separately, make sure you invoke the correct version by using the full path.
79
109
80
-
Travis CI looks for `phpunit` in the [same order as Composer does](https://getcomposer.org/doc/articles/vendor-binaries.md#can-vendor-binaries-be-installed-somewhere-other-than-vendor-bin-)
110
+
Travis CI looks for `phpunit` in the [same order as Composer
1. `phpunit` found in the directory specified by `bin-dir` in `composer.json`
85
116
1. `vendor/bin/phpunit`
86
117
1. `phpunit`, which is found on `$PATH` (typically one that is pre-packaged with the PHP runtime)
87
118
88
-
If your project uses something other than PHPUnit, you can [override the default test command](/user/customizing-the-build/).
119
+
If your project uses something other than PHPUnit, you can [override the default build script](/user/customizing-the-build/).
89
120
90
121
### Working with atoum
91
122
@@ -97,9 +128,12 @@ script: vendor/bin/atoum
97
128
```
98
129
{: data-file=".travis.yml"}
99
130
100
-
## Dependency Management (a.k.a. vendoring)
131
+
## Dependency Management
101
132
102
-
Before Travis CI can run your test suite, it may be necessary to pull down your project dependencies. It can be done using a PHP script, a shell script or anything you need. Define one or more commands you want Travis CI to use with the *install* option in your .travis.yml, for example:
133
+
Before Travis CI can run your test suite, it may be necessary to install your
134
+
project dependencies. It can be done using a PHP script, a shell script or
135
+
anything you need. Define one or more commands you want Travis CI to use with
136
+
the *install* option in your `.travis.yml`, for example:
103
137
104
138
```yaml
105
139
install: php vendor/vendors.php
@@ -115,11 +149,11 @@ install:
115
149
```
116
150
{: data-file=".travis.yml"}
117
151
118
-
Even though installed dependencies will be wiped out between builds (VMs we run tests in are snapshotted), please be reasonable about the amount of time and network bandwidth it takes to install them.
119
-
120
-
### Testing Against Multiple Versions of Dependencies (e.g. Symfony)
152
+
### Testing Against Multiple Versions of Dependencies
121
153
122
-
If you need to test against multiple versions of, say, Symfony, you can instruct Travis CI to do multiple runs with different sets or values of environment variables. Use *env* key in your `.travis.yml` file, for example:
154
+
If you need to test against multiple versions of, say, Symfony, you can instruct
155
+
Travis CI to do multiple runs with different sets or values of environment
156
+
variables. Use *env* key in your `.travis.yml` file, for example:
123
157
124
158
```yaml
125
159
env:
@@ -128,9 +162,12 @@ env:
128
162
```
129
163
{: data-file=".travis.yml"}
130
164
131
-
and then use ENV variable values in any later script like your dependencies installation scripts, test cases or test script parameter values.
165
+
and then use ENV variable values in any later script like your dependencies
166
+
installation scripts, test cases or test script parameter values.
132
167
133
-
Here is an example using the above ENV variable to modify the dependencies when using the composer package manager to run the tests against the 2 different versions of Symfony as defined above.
168
+
Here is an example using the above ENV variable to modify the dependencies when
169
+
using the composer package manager to run the tests against the 2 different
See the [default configure options](https://github.com/travis-ci/travis-cookbooks/blob/precise-stable/ci_environment/phpbuild/templates/default/default_configure_options.erb) to get an overview of the core extensions enabled.
244
-
245
-
### Preinstalled PHP extensions
246
-
247
-
#### PHP 7.0
248
-
249
-
The following extensions are preinstalled for PHP 7.0 and nightly builds:
250
-
251
-
- [apcu.so](http://php.net/apcu)
252
-
- [memcached.so](http://php.net/memcached)
253
-
- [mongodb.so](https://php.net/mongodb)
254
-
- [amqp.so](http://php.net/amqp)
255
-
- [zmq.so](http://zeromq.org/bindings:php)
256
-
- [xdebug.so](http://xdebug.org)
257
-
- [redis.so](http://pecl.php.net/package/redis)
258
-
259
-
Please note that these extensions are not enabled by default with the exception of xdebug.
260
-
261
-
#### PHP 5.6 and below
262
-
263
-
For PHP versions up to 5.6, the following extensions are available:
264
-
265
-
- [apc.so](http://php.net/apc) (not available for 5.5 or 5.6)
266
-
- [memcache.so](http://php.net/memcache) or [memcached.so](http://php.net/memcached)
267
-
- [mongo.so](http://php.net/mongo)
268
-
- [amqp.so](http://php.net/amqp)
269
-
- [zmq.so](http://zeromq.org/bindings:php)
270
-
- [xdebug.so](http://xdebug.org)
271
-
- [redis.so](http://pecl.php.net/package/redis)
272
-
273
-
Please note that these extensions are not enabled by default with the exception of xdebug.
274
-
275
-
### Enabling preinstalled PHP extensions
276
+
## Enabling preinstalled PHP extensions
276
277
277
278
You need to enable them by adding an `extension="<extension>.so"` line to a PHP configuration file (for the current PHP version).
278
279
The easiest way to do this is by using `phpenv` to add a custom config file which enables and eventually configure the extension:
To disable xdebug, add this to your configuration:
305
306
@@ -309,43 +310,49 @@ before_script:
309
310
```
310
311
{: data-file=".travis.yml"}
311
312
312
-
### Installing additional PHP extensions
313
+
## Installing additional PHP extensions
314
+
315
+
It is possible to install custom PHP extensions into the Travis CI environment
316
+
using [PECL](http://pecl.php.net/), but they have to be built against the PHP
317
+
version being tested.
313
318
314
-
It is possible to install custom PHP extensions into the Travis CI environment using [PECL](http://pecl.php.net/), but they have to be built against the PHP version being tested. Here is for example how the `memcache` extension can be installed:
319
+
For example, to install `memcache`:
315
320
316
321
```
317
322
pecl install <extension>
318
323
```
319
324
320
-
PECL will automatically enable the extension at the end of the installation. If you want to configure your extension, use the `phpenv config-add` command to add a custom ini configuration file in your before_script.
325
+
PECL will automatically enable the extension at the end of the installation. If
326
+
you want to configure your extension, use the `phpenv config-add` command to add
327
+
a custom ini configuration file in your before_script.
321
328
322
-
It is also possible to do the installation "manually", but you'll have to manually enable the extension after the installation either with `phpenv config-add` and a custom ini file or with this one line command:
329
+
It is also possible to do the installation "manually", but you'll have to
330
+
manually enable the extension after the installation either with `phpenv
331
+
config-add` and a custom ini file or with this one line command:
See also the [full script using midgard2](https://github.com/bergie/midgardmvc_core/blob/master/tests/travis_midgard2.sh).
329
338
330
-
If you need specific version of preinstalled extension, you need to force install specific version with the `-f` flag. For example:
339
+
If you need specific version of preinstalled extension, you need to force
340
+
install specific version with the `-f` flag. For example:
331
341
332
342
```
333
343
pecl install -f mongo-1.2.12
334
344
```
335
345
336
-
#### Note on `pecl install`
346
+
### Note on `pecl install`
337
347
338
348
Note that `pecl install` can fail if the requested version of the package is already installed.
339
349
340
-
### Chef Cookbooks for PHP
341
350
342
-
If you want to learn all the details of how we build and provision multiple PHP installations, see our [php, phpenv and php-build Chef cookbooks](https://github.com/travis-ci/travis-cookbooks/tree/precise-stable/ci_environment).
343
351
344
352
### Apache + PHP
345
353
346
-
Currently Travis CI does not support mod_php for apache, but you can configure php-fpm for your integration tests.
347
-
348
-
In your .travis.yml:
354
+
Currently Travis CI does not support `mod_php` for apache, but you can configure
355
+
`php-fpm` for your integration tests:
349
356
350
357
```yaml
351
358
before_script:
@@ -363,9 +370,10 @@ before_script:
363
370
```
364
371
{: data-file=".travis.yml"}
365
372
366
-
> Note that `sudo` is not available for builds that are running on [container-based](/user/workers/container-based-infrastructure) workers.
373
+
> Note that `sudo` is not available for builds that are running on [container-based](/user/workers/container-based-infrastructure).
367
374
368
-
You will need to have `build/travis-ci-apache` file that will configure your virtual host as usual, the important part for php-fpm is this:
375
+
You will need to have `build/travis-ci-apache` file that will configure your
376
+
virtual host as usual, the important part for php-fpm is this:
369
377
370
378
```apacheconf
371
379
<VirtualHost *:80>
@@ -392,24 +400,6 @@ You will need to have `build/travis-ci-apache` file that will configure your vir
392
400
</VirtualHost>
393
401
```
394
402
395
-
## PHP nightly builds
396
-
397
-
Travis CI offers ability to test your PHP applications with a recent build of
398
-
[PHP](https://github.com/php/php-src/).
399
-
400
-
You can specify this with:
401
-
402
-
```yaml
403
-
language: php
404
-
405
-
php:
406
-
- nightly
407
-
```
408
-
{: data-file=".travis.yml"}
409
-
410
-
This installation includes PHPUnit and Composer, and also has
Copy file name to clipboardExpand all lines: user/reference/precise.md
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -264,17 +264,21 @@ Test::Pod::Coverage
264
264
265
265
## PHP VM images
266
266
267
+
268
+
267
269
### PHP versions
268
270
269
271
PHP runtimes are built using [php-build](https://github.com/CHH/php-build).
270
272
271
-
[hhvm](https://github.com/facebook/hhvm) is also available.
272
-
and the nightly builds are installed on-demand (as `hhvm-nightly`).
273
-
274
273
### XDebug
275
274
276
275
Is supported.
277
276
277
+
### Core extensions
278
+
279
+
See the [default configure options](https://github.com/travis-ci/travis-cookbooks/blob/precise-stable/ci_environment/phpbuild/templates/default/default_configure_options.erb) to get an overview of the core extensions enabled.
280
+
281
+
278
282
### Extensions
279
283
280
284
```
@@ -340,6 +344,11 @@ zlib
340
344
Xdebug
341
345
```
342
346
347
+
### Chef Cookbooks for PHP
348
+
349
+
If you want to learn all the details of how we build and provision multiple PHP installations, see our [php, phpenv and php-build Chef cookbooks](https://github.com/travis-ci/travis-cookbooks/tree/precise-stable/ci_environment).
0 commit comments