October 4, 2022

Setting Your PHP 7.4 Migration Strategy

State of PHP
Modernization

With PHP 7.4 end of life set to hit at the end of November, teams with applications built on PHP 7.4 are quickly planning and executing their migration to a community-supported version. But are there considerations teams need to make when migrating PHP 7.4?

In this blog, we look at considerations for teams migrating off PHP 7.4, including backwards compatibility, deprecated features, potential migration paths, and what teams can do if they're  not able to migrate before PHP 7.4 reaches end of life.

Before You Migrate From PHP 7.4

Because PHP 7.4 is the terminal release for the PHP 7.x series, migrating PHP 7.4 requires users to migrate to a new major version of PHP, PHP 8. With this jump to a new major version, there is typically an increased number of considerations, including backwards incompatibility, deprecated features, and other changes.

Backwards Incompatibility 

When you migrate to a new major version, the chances of experiencing issues with backwards incompatibility goes up. For teams moving from PHP 7.4 to PHP 8, there is a long list of changes that might impact your applications. They range from changes to the core language, to how objects within the language are treated, to the removal and deprecation of features and functions. You can view the full list of backwards incompatible changes here.

Deprecated Features and Other Changes

There are a number of features that previously appeared in PHP 7.4 that are deprecated in PHP 8. The deprecated features list for PHP 8.0.x can be found here.

Any other changes that might impact teams migrating from PHP 7.4 to PHP 8 can be found in the "Other Changes" list.

Start Planning Your Next PHP Migration

image showing illustration of php migration

In this free white paper, our experts provide insights on the best practices for planning and executing successful PHP migrations and upgrades.

Download for Free

Picking the Right PHP 7.4 Migration Path

Now that PHP 8.1 is available, most teams will be migrating from PHP 7.4 directly to 8.1. However, with a second release candidate for PHP 8.2 now available (and a GA release coming soon), some teams may hold off on upgrading until 8.2 is available. 

Migrating PHP 7.4 to PHP 8.0

As noted in our blog covering the new features and improvements in PHP 8.0, there are a number of syntactical improvements that simplify boilerplate, with some very handy expansions to the type systems. The PHP JIT compiler, although a banner feature for the release, probably won't be the reason why teams migrate to 8.0 or 8.x versions (at least until there are mature libraries and applications that take advantage of it).

As noted above, major version changes bring about a number of backward incompatibilities, meaning that teams will need to spend time reviewing their code. Luckily, there are a few tools that can give you a head start when performing your thorough testing, like the PHP Compatibility Coding Standard for PHP CodeSniffer.

Read our breakdown of the new features in PHP 8.0 >>

Migrating PHP 7.4 to PHP 8.1

For teams who want to migrate to the latest version of PHP (as of September 29, 2022), the migration path would typically run from PHP 7.4 directly to PHP 8.1. PHP 8.1 introduced a few new features, changes, and deprecations to watch out for, so be sure to read the full release notes and upgrade notes.

As we noted in our blog detailing the new features in PHP 8.1, teams will want to consider PHP 8.1 or 8.2 if they want to take advantage of the improvements to the object model, or the async capabilities of fibers. Teams upgrading to 8.1 will want to watch out for changes to mysqli error mode, and how values are tied to other types when strict types are enabled.

Read our breakdown of the big changes in PHP 8.1 >> 

Migrating PHP 7.4 to PHP 8.2 Preview Releases

PHP 8.2 (as of September 29, 2022) is currently in its buildup to a general availability release, having already released two release candidates. (Note: PHP 8.1 had six release candidates before it reached GA).

While release candidates aren't suitable for production, teams can generally start using release candidates in their test environments in preparation for the GA release (and help out the PHP community to improve the release by reporting issues). The PHP community provides a list of upgrade notes (E.g., PHP 8.2 RC2) for each release candidate and GA release to help teams review their upgrade path.

An additional consideration for teams that want to preview upcoming versions in their test environments is that tools like the PHP Compatibility Coding Standard for PHP CodeSniffer noted above won't have updated their standards for the upcoming version, so there won't be any shortcuts available. The same is true for 3rd party libraries and frameworks, with most of these libraries and frameworks releasing supported versions for the PHP version only after it reaches GA.

Teams might consider PHP 8.2 over 8.1 or 8.0 if they are interested in readonly classes, standalone types, or want slightly better performance.

Read our breakdown of the changes to watch in PHP 8.2 >>

What If You Can’t Migrate Before End of Life?

For teams migrating particularly complex or numerous PHP applications, migrating your applications to supported PHP versions before they reach end of life might not always be possible or cost-effective. But that doesn't mean that teams can roll the dice on unsupported PHP in their applications. Teams that use unsupported PHP in production risk exposing their applications and data to unpatched vulnerabilities.

To prevent exposure to those vulnerabilities, teams need to have a plan in place for patching vulnerabilities as they arise — whether that's building patches in house, or working with a third party LTS provider like Zend.

See our PHP LTS options >>

Final Thoughts

With PHP 7.4 reaching end of life at the end of November, teams who haven't already planned a migration need to start planning and execute their migration strategy, or find a way to support their EOL PHP. 

That said, if it makes business sense for your team to migrate your application(s) onto a newer, supported PHP version, they should. When they do, they are likely to enjoy a number of new features, improvements, and potential cost savings that come with it.

See Our PHP LTS and Migration Service Options

Whether you need to migrate PHP-based applications to a new version, or find extended long-term support to keep your applications safe and secure, Zend can help. See what we offer via the links below.

See LTS Options See Migration Services

Additional Resources