PHP 7.1: testing a pre-releaseSeptember 06, 2016 —
Cet article est aussi disponible en français.
Knowing PHP 7.1 will bring us some nice new features is great. But being able to play with those by ourselves is much better!
Like with any PHP version, you can proceed several ways. You can compile PHP yourself, look for a docker image built by a community member, or trust a maintainer who could already have packaged PHP 7.1 for your distro.
Compiling PHP by Hand
The most typical approach, when it comes to testing a future release of PHP (or any other specific version), is to get PHP source-code and compile it. I’ll write here the couple of commands you’ll have to run with Ubuntu 14.04.
But before, there are a few prerequisites you must install. Here, to compile PHP with the options (including extensions) I’ll be using later on:
sudo apt-get install build-essential re2c bison libicu-dev
The next step is to download the sources. You get can them from the project’s Git repository:
git clone https://git.php.net/repository/php-src.git php-src cd php-src git checkout PHP-7.1
- qa.php.net for packages containing the next release;
- or the mirror php/php-src on Github.
After those sources are downloaded and/or decompressed, on to the typical
make install triplet:
./buildconf ./configure --prefix=$HOME/bin/php-7.1 \ --disable-all \ --enable-pcntl \ --enable-intl \ --enable-mbstring make -j 4 -l 6 make install
⚠ I only enabled a few extensions here. For a PHP build that fits closer to the needs of your application, you’ll probably have to enable a couple of others. Invoke
./configure --help to list all possible configuration options—and don’t forget to install the dependencies you might need.
Finally, to check your setup:
$ ~/bin/php-7.1/bin/php --version PHP 7.1.0-dev (cli) (built: Aug 13 2016 18:17:29) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
If you are working with Windows, you should take a look at build your own PHP on Windows.
PHP 7.1 and docker?
It’s still a bit early for PHP 7.1 to be in the official image provided by Docker: php.
A few images, not really used much for now, are available here and there. Else, feel free to build your own — based on the compilation instructions given earlier, for instance ;-)
Some repositories with PHP 7.1?
You will probably not find PHP 7.1 in all official distributions’ repositories, as it’s not stable yet.
Still, if you are using Fedora / RHEL / CentOS, PHP 7.1 has been packaged by Remi Collet: PHP on the road to the 7.1.0 release.
And for Ubuntu, you’ll find PHP 7.1 in Ondřej Surý’s repo. For more details: The main PPA for PHP (5.5, 5.6, 7.0).
That’s it for today! Let’s meet again tomorrow, for a first post really presenting new features of PHP 7.1!