Accepting selected projects for Q2 2024 Check availability →
SERVER 02SYSTEM ONLINELAST SYNC: 03:17:44RSS 2.0 — ONLINE
HALF ASSEDTECHNICAL NOTES_
EST. 1999ISSUE 04.2BEST VIEWED AT 1024 × 768
TECHNICAL NOTES / PRACTICAL GUIDES / PLATFORM / RECORD 3e16fe
[PLATFORM]GUIDE

Moving a legacy application from PHP 5.6 to PHP 7.1

POSTED: 12.09.2017AUTHOR: ADMIN10 MIN READCOMMENTS: 0

PHP 7 offers substantial performance and memory improvements, but it removes long-deprecated functions and changes how some expressions are evaluated. An established application should be upgraded by audit and test, not by changing the package version on the server.

Inventory the runtime

Record the PHP version, loaded extensions and ini settings on each environment, together with Composer dependencies and any code copied into the project by hand. Confirm that each library and each PECL extension has a release that supports 7.1 before estimating the application work.

Find removed functionality

Search for the mysql extension, the ereg functions, the preg_replace /e modifier and other features removed in PHP 7.0. Run a static compatibility check such as the PHPCompatibility standard for PHP_CodeSniffer and treat its report as a starting list rather than a complete one.

Review changed behaviour

Examine code affected by uniform variable syntax, the new Error exception hierarchy, changes to list() and foreach, and integer handling. Note that mcrypt is deprecated in 7.1; replace it with OpenSSL or libsodium now rather than carrying it into the next upgrade.

Test on a parallel environment

Build a PHP 7.1 environment that matches production extensions and data, then run the automated suite and the manual journeys the suite does not cover. Log deprecations and notices to a file and resolve them; do not suppress error reporting to obtain a clean run.

Release with a route back

Move a portion of traffic or a single node first where the architecture permits, compare error rates and response times, and keep the 5.6 pool available until scheduled jobs, command-line scripts and month-end processes have each run successfully.

SUPPORT DATES

PHP 5.6 receives security fixes only until 31 December 2018, and PHP 7.0 leaves support earlier in the same month. Target 7.1 or later so the upgrade is not repeated within a year.