Skip to content

Commit c41cce7

Browse files
authored
Merge branch 'master' into sw-trusty-clojure
2 parents dbe65bc + 7a231eb commit c41cce7

File tree

3 files changed

+186
-123
lines changed

3 files changed

+186
-123
lines changed

user/languages/php.md

Lines changed: 103 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -4,88 +4,119 @@ layout: en
44

55
---
66

7-
### What This Guide Covers
7+
<div id="toc">
8+
</div>
89

9-
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+
<aside markdown="block" class="ataglance">
1011

11-
PHP builds are not available on the OS X environment.
12+
| PHP | Default |
13+
|:--------------------------------------------|:------------------------------------------|
14+
| [Default `install`](#Dependency-Management) | N/A |
15+
| [Default `script`](#Default-Build-Script) | `phpunit` |
16+
| [Matrix keys](#Build-Matrix) | `env`, `php` |
17+
| Support | [Travis CI](mailto:[email protected]) |
18+
19+
Minimal example:
20+
21+
```yaml
22+
language: php
23+
php:
24+
- '5.6'
25+
- '7.1'
26+
- hhvm # on Trusty only
27+
- nightly
28+
```
29+
30+
</aside>
31+
32+
## What This Guide Covers
33+
34+
{{ site.data.snippets.trusty_note_no_osx }}
1235
13-
<div id="toc"></div>
36+
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.
1441
1542
## Choosing PHP versions to test against
1643
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.
1847
19-
A minimalistic `.travis.yml` file would look like this:
48+
An example `.travis.yml` file that tests various PHP versions:
2049

2150
```yaml
2251
language: php
2352
php:
2453
- '5.4'
25-
- '5.5'
2654
- '5.6'
2755
- '7.0'
28-
- '7.1'
2956
- hhvm # on Trusty only
3057
- nightly
3158
```
3259
{: data-file=".travis.yml"}
3360

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.
3563

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.,
4365

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"}
4572

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.
4778

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.
4979

5080
### HHVM versions
5181

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:
5383

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
5591

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:
5795

5896
```yaml
5997
language: php
60-
sudo: required
61-
dist: trusty
62-
group: edge
98+
6399
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
71101
```
72102
{: data-file=".travis.yml"}
73103

74-
## Default Test Script (PHPUnit)
104+
## Default Build Script
75105

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
77107
install a specific version in a custom location. If you do install it
78108
separately, make sure you invoke the correct version by using the full path.
79109

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
111+
does](https://getcomposer.org/doc/articles/vendor-binaries.md#can-vendor-binaries-be-installed-somewhere-other-than-vendor-bin-)
81112
and uses the first one found.
82113

83114
1. `$COMPOSER_BIN_DIR/phpunit`
84115
1. `phpunit` found in the directory specified by `bin-dir` in `composer.json`
85116
1. `vendor/bin/phpunit`
86117
1. `phpunit`, which is found on `$PATH` (typically one that is pre-packaged with the PHP runtime)
87118

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/).
89120

90121
### Working with atoum
91122

@@ -97,9 +128,12 @@ script: vendor/bin/atoum
97128
```
98129
{: data-file=".travis.yml"}
99130

100-
## Dependency Management (a.k.a. vendoring)
131+
## Dependency Management
101132

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:
103137

104138
```yaml
105139
install: php vendor/vendors.php
@@ -115,11 +149,11 @@ install:
115149
```
116150
{: data-file=".travis.yml"}
117151

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
121153

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:
123157

124158
```yaml
125159
env:
@@ -128,9 +162,12 @@ env:
128162
```
129163
{: data-file=".travis.yml"}
130164

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.
132167

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
170+
versions of Symfony as defined above.
134171

135172
```yaml
136173
install:
@@ -236,43 +273,7 @@ before_script: echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$(php
236273
```
237274
{: data-file=".travis.yml"}
238275

239-
## PHP extensions
240-
241-
### Core extensions
242-
243-
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
276277

277278
You need to enable them by adding an `extension="<extension>.so"` line to a PHP configuration file (for the current PHP version).
278279
The easiest way to do this is by using `phpenv` to add a custom config file which enables and eventually configure the extension:
@@ -299,7 +300,7 @@ before_install: echo "extension = <extension>.so" >> ~/.phpenv/versions/$(phpenv
299300
```
300301
{: data-file=".travis.yml"}
301302

302-
### Disabling preinstalled PHP extensions
303+
## Disabling preinstalled PHP extensions
303304

304305
To disable xdebug, add this to your configuration:
305306

@@ -309,43 +310,49 @@ before_script:
309310
```
310311
{: data-file=".travis.yml"}
311312

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.
313318

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`:
315320

316321
```
317322
pecl install <extension>
318323
```
319324

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.
321328

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:
323332

324333
```
325334
echo "extension=<extension>.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
326335
```
327336

328337
See also the [full script using midgard2](https://github.com/bergie/midgardmvc_core/blob/master/tests/travis_midgard2.sh).
329338

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:
331341

332342
```
333343
pecl install -f mongo-1.2.12
334344
```
335345

336-
#### Note on `pecl install`
346+
### Note on `pecl install`
337347

338348
Note that `pecl install` can fail if the requested version of the package is already installed.
339349

340-
### Chef Cookbooks for PHP
341350

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).
343351

344352
### Apache + PHP
345353

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:
349356

350357
```yaml
351358
before_script:
@@ -363,9 +370,10 @@ before_script:
363370
```
364371
{: data-file=".travis.yml"}
365372

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).
367374

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:
369377

370378
```apacheconf
371379
<VirtualHost *:80>
@@ -392,24 +400,6 @@ You will need to have `build/travis-ci-apache` file that will configure your vir
392400
</VirtualHost>
393401
```
394402

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
411-
[some extensions](#PHP-7.0){: data-proofer-ignore=""}.
412-
413403
## Build Matrix
414404

415405
For PHP projects, `env` and `php` can be given as arrays

user/reference/precise.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,21 @@ Test::Pod::Coverage
264264

265265
## PHP VM images
266266

267+
268+
267269
### PHP versions
268270

269271
PHP runtimes are built using [php-build](https://github.com/CHH/php-build).
270272

271-
[hhvm](https://github.com/facebook/hhvm) is also available.
272-
and the nightly builds are installed on-demand (as `hhvm-nightly`).
273-
274273
### XDebug
275274

276275
Is supported.
277276

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+
278282
### Extensions
279283

280284
```
@@ -340,6 +344,11 @@ zlib
340344
Xdebug
341345
```
342346
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).
350+
351+
343352
## Python VM images
344353
345354
### Python versions

0 commit comments

Comments
 (0)