Should You Update to PHP 8?
2021 will be an exciting year for PHP developers and applications. PHP 8 released in 2020, marking the next major update of the PHP language. After 5 years of well-loved PHP 7.0 versions, the latest update contains many new features, performance improvements, and will most likely introduce breaking changes.
This all begs the question: Should you update to PHP 8, or is it better to wait?
Let’s take a quick look at what the latest update contains, and what you should consider before updating.
What’s New in PHP 8
While the update does not introduce revolutionary changes in the language, there’s a lot of great stuff in PHP 8 (which you can download here). There are many changes, including named arguments, union types, attributes, constructor property promotion, match expressions, throw expressions, null safe operator, JIT, and improvements in the type system, error handling, and consistency—just to name a few! Head over to the official PHP 8.0 Upgrade Notes for a list of all changes.
On the language front, there are two changes in PHP 8 which deserve special attention:
The Just in Time (JIT) compiler promises to speed up more complex, longer-running scripts. Currently, it can improve code execution performance and will expand and improve over time, as more people tinker with it.
- Tidy comparison operator
Better comparisons will get rid of frequent bugs and unexpected behaviors that often plague PHP developers. Comparisons between numbers and non-numeric strings now work. Thank goodness!
Should you update now to PHP 8?
The short and sweet answer is ‘Yes.’
This is universally true, at least in the world of PHP development. Applications that run on the latest versions of both PHP—and their supporting frameworks and libraries—make it possible to develop new features and maintain the codebase more efficiently.
How easy is it to update to PHP 8?
Do your frameworks and libraries support PHP 8? If so, updating should be straightforward. Nearly all the major, popular frameworks now have PHP 8 support enabled.
We’re only a few months behind the new release, so some 3rd party dependencies are still catching up on compatibility and fixes intended for their developers. For instance, legacy PHP codebases, like WordPress, will still run into compatibility issues.
Lesser-known libraries and packages may be less friendly as well. In this case, each one will have to be updated before proceeding. If you can’t upgrade to PHP 8.0 because of your dependencies, we encourage you to support open-source activities, whether in their development or even in feedback to those who create them. You can always ask or check their Twitter account to get the latest news on their support roadmap for PHP 8.
How much time do you have?
This depends on your current PHP version in use.
The release of PHP 8 coincides with support ending for versions 7.1 and 7.2. Version 7.3 has now entered the Security Support period, which means it will only receive security fixes. If your application uses any of the above versions (or, horror of horrors, earlier ones) you should prioritize a roadmap for upgrading to PHP 8 immediately!
If you are on PHP 7.4.x, you still have a whole year to update without worrying about version support. Of course, this means you still won’t have access to the latest features available in PHP 8.0.
Polcode is on PHP 8!
Our first internal application has already been updated to PHP 8 in production. Our projects keep up with the latest releases, so migrating was simple and easy, as most of the breaking changes were deprecated before the 7.x versions. We’re also in the process of migrating a few of our clients to the new version.
If you’re on 7.4.x, the migration guide has all the documentation you need. This resource also contains all of the new features and backward-incompatible changes that you’ll have to look out for when migrating versions.
Let us know how your update goes. Don’t wait too long!
Need help with updating to PHP 8? Contact us now!