PHP Major Upgrade to Version 8

October 4th, 2022 by Ammu Nair

Over the past few months, we have been busy upgrading our client websites to PHP version 8; the most recent significant version release.

PHP is one of the most widely used programming languages on the internet, powering nearly 80% of all websites, including popular Content Management Systems like WordPress, Drupal, Magento etc. For the most part, you do not directly interact with PHP, however the reality is your website CMS and other important software components running your website or application relies on PHP to work.

Whilst the regular PHP upgrades we carry out are minor, involving small bug fixes and addressing known security vulnerabilities (known as non-breaking upgrades), a major version upgrade (from 7.x to 8.x) is different.  Major upgrades are packed with significant improvements to performance and security, and therefore affect far more of the language than a minor update.

We are excited to describe in this article, the most interesting optimizations delivered through PHP 8.1, that will help keep your website robust, secure and performing well.

PHP JIT (Just In Time Compiler)

Simply put, JIT monitors your code for functions that repeat frequently and “preload” them to save time and computing resources. JIT will increase the speed of PHP 8 websites and web applications. A performance review conducted by Phoronix determined a performance increase of 7% when switching from PHP 7.4 to PHP 8.0 and a more than 50% increase when using PHP 8.0 with JIT compiler compared to PHP 8.0 without JIT compiler:

JIT, due to the way it works is expected to provide a performance boost mainly to CPU intensive applications, and a slight performance improvement to typical PHP web applications. However, JIT has done wonders for other scripting languages in the past and will open doors to new possibilities that were not previously feasible to PHP. Depending on how deeply you utilise JIT, the downside may be greater complexity and therefore increased development and maintenance costs.

PHP version 8 benchmark

Security vs Fault Tolerance

PHP 8.0 has also removed some previously supported functions in order to make the language more secure. While PHP has consistently been fault tolerant (meaning that it prioritizes code execution over minor violations to conventions which have traditionally just thrown a warning), in many cases the newest version tightens up this area by throwing an error instead of warnings. This means that your website code might need to be modified to run correctly.

Other Changes

A few general changes have also been made to the language. Some pre-loaded functions such as create_function() and each() have been removed, while the mechanism and working of quite a few functions have been modified. The new version is beyond any doubt a step towards cleaning up the language and releasing a lot of long-awaited improvements.

The entire list of changes introduced in PHP8.0 has been published on the PHP website and can be accessed from https://www.php.net/releases/8.0/en.php.

Things to Consider Prior to Upgrading

Before upgrading to PHP, there are some important aspects of your website environment that need to be prepared.

  • Server readiness: you need to ensure that the web hosting provider for your application or website is ready to run PHP 8.0. If your website runs on PHP or WordPress and you are not sure if your webserver will support an upgrade to PHP 8, we would be pleased to evaluate your website and assist you with the upgrade.
  • Is your website running on a CMS?: WordPress has already released version 5.6 which is compatible with PHP 8.0. In fact, performance benchmark results show that PHP 8.1 can handle 50% more requests (or transactions) per second, as compared to PHP 7.4 (https://kinsta.com/blog/php-benchmarks/#php-benchmarks-2022).
  • Themes & Plugins:  As part of upgrading PHP where a CMS is in place, it is also essential to ensure the compatibility of themes and plugins.  Similarly, if your website is running on Laravel or any other PHP based CMS, you will need to make sure that the Laravel version being used by your website can operate on PHP v8.0.

When to Upgrade

PHP 8.0 was officially released in November 2020, causing plenty of buzz in the PHP community with reviews and experiences of features introduced in the release. Over the last 2 years, PHP 8.0 has become widely accepted as a stable version with the PHP coding community ready to support any issues or risks posed by the upgrade.

The End of Life period for PHP v7.4 is fast approaching, which means that after November 2022, if you are faced with any security vulnerabilities on your application running PHP v7.4 or older, you are own your own; the PHP community would not assist you in addressing your issues. This means NOW is certainly the time to upgrade your website or application to the latest version of PHP.

Whilst PHP v8.x has introduced several breaking changes, it also provides numerous optimisations and long-awaited features, allowing developers to write shorter, structured, robust and more readable code. In addition to security improvements, improved performance and shorter loading and access times are the positive consequences of PHP 8.0 and truly justify the effort to update to this version.

Facebooktwitterredditpinterestlinkedinmailby feather

Leave a Reply

Subscribe to our monthly

Contactpoint Email News

Our enews is sent out approximately monthly, and contains information on latest digital technologies, and how these can be used to help your organisation grow.

To subscribe, simply fill in your details below: