< PHP

PHP/Upgrading to PHP 7.1

Compatibility check[edit | edit source]

PHP 7 has some major changes from the previous 5.x versions. All scripts should be checked before upgrading.

PHP 7 Compatiblity Checker is a wonderful tool to do this automatically.

PHP Static Analysis Tool is an amazing tool to check your code as if it was running. This is beyond syntax checking.

PHP Targets[edit | edit source]

To upgrade a system to PHP 7.1, first set the PHP_TARGETS variable in make.conf:

FILE /etc/portage/make.confSetting the target PHP version
PHP_TARGETS="php7-1"

Installation[edit | edit source]

Install PHP 7.1:

root #emerge --ask dev-lang/php:7.1

Replace APC[edit | edit source]

To build with the opcache USE flag (the default) while allowing the use of APC userland functions such as apc_fetch(), install APCu, which emulates APC but only has user caching functions. This may be necessary for older projects that rely on APC for caching.

Install APCu:

root #emerge --ask dev-php/pecl-apcu

The PHP 7 versions of pecl-apcu have a new syntax which need changes to support. Fortunately, there is a compatibility package, dev-php/pecl-apcu_bc:

root #emerge --ask dev-php/pecl-apcu_bc

Switch to PHP 7.1[edit | edit source]

Switch to it using eselect for all SAPIs:

root #eselect php set cli php7.1
root #eselect php set fpm php7.1

When other SAPIs are in use, be sure to run eselect for those as well.

Re-install compatible extensions[edit | edit source]

Since changing PHP_TARGETS is technically a USE flag change, it suffices to simply emerge @world with flags checking for new USE flags and all extensions should re-build.

root #emerge --ask --changed-use --deep @world

Migrate the configuration files[edit | edit source]

The different slots have different configuration paths. Please take care to migrate the configuration files before making use of a new slot.

Uninstall old PHP versions[edit | edit source]

For example, to remove PHP 5.6:

root #emerge --ask -vc dev-lang/php:5.6

Restart PHP-FPM[edit | edit source]

Restart PHP-FPM if applicable:

root #/etc/init.d/php-fpm restart
This article is issued from Gentoo. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.