PHP 8: The importance of staying up-to-date with your webshop

PHP 8: The importance of staying up-to-date with your webshop

A new version of PHP has been available for some time now: PHP 8. Perhaps you have already heard a few things about this. You might have even received a message that your webshop is running on an outdated version of PHP.

Now the question arises: “Why should I upgrade my webshop?” In this article we will briefly discuss the new features within PHP 8 and the compatibility of PHP 8 in Magento 2. We will go over what you may need to consider when upgrading to PHP 8 and – most importantly – why it is smart to always stay up-to-date.

 

 

Updating PHP 8Why Upgrade

 

Let’s start with the most important thing. Although we will not stop supporting lower versions of PHP at MageHost, we would like to urge you all to upgrade to PHP 7.4 at the very least. Why? Because this is the lowest version of PHP that is still actively supported by PHP itself. In 2019, for example, 90% of all webshops were running on an outdated version of PHP. This deserves attention. Especially considering that staying up-to-date is a must. All the more so for sites that process personal data. There are a number of important reasons for this, which we would like to explain to you. 

Icon Security Security

You hear, read and see a lot about it: security is extremely important, especially for webshops. And yet, a lot of webshops use oudates versions of PHP. As stated in the last paragraph. You can compare it to banking on a laptop that runs on Windows 98… quite unsafe. This may sound a bit extreme, but if your webshop runs on a PHP version that is no longer supported, you expose your webshop to all kinds of dangers. Dangers such as hacking that can be prevented by upgrading.

Icon performance Performance

Staying up-to-date is also beneficial for the performance of your webshop. Until now, with every update of PHP the performance has improved. This of course depends on the type of webshop you have. However, in general upgrading can often help to speed up your site. If your webshop is currently running on an outdated version of PHP, it could be that the performance has deteriorated enormously over the past few years. This can be caused by plug-ins that no longer work properly with an outdated version of PHP. That could’ve happend because these plug-ins are only optimised for newer versions of PHP. This ultimately results in a low performing website.

Icon Accountability Accountability

Lastly, it is important to realise that you, as a webshop owner, have a duty of accountability. The AVG (General Data Protection Regulation in the Netherlands) states that you are responsible for demonstrating that your website complies with the privacy regulations. This also includes keeping software up-to-date. If your webshop runs on a PHP version that is no longer supported and if this causes data leaks, for example, it could have major consequences. In such a case, this could mean that you are directly responsible for compromising the security of sensitive data as a result of overdue maintenance on the webshop. This in turn means that you are not complying with the AVG guidelines. This often leads to fines: so pay close attention to this.

What is new in PHP 8

A number of things have changed in this new version of PHP, which was released in November 2020. New functions have been added, but also removed. Below we are listing some of the benefits and useful new features that have been added to PHP 8.

Benefits: 

  • JIT Compiler: This function improves the speed of loading PHP scripts even further. This makes your webshop faster.
  • JSON Support: Where previously JSON support was optional, it is now a core feature that is always available.
  • Support for Attributes: Previously this option was not supported and programmers had to find a way around it themselves to assign machine-readable metadata such as class to code. Now that this is a standard feature, there is no need to come up with workarounds.

Drawbacks: 

One major change that may have a negative effect is that PHP 8 is a lot stricter with the code it receives. Where you previously received a warning in 7.4, you will now receive an error message. Another disadvantage is that there may still be existing plug-ins or programs within your webshop that are not yet fully compatible with the latest version of PHP. It is therefore important to pay attention to this when making the switch. This will prevent errors in your webshop.

Compatibility PHP 8 and Magento 2

By starting the Magento Community Project, the latest version of Magento (Magento 2.4) is compatible with the latest version of PHP (PHP 8.1). However, we have noticed that not all platforms and plug-ins are 100% compatible. Should you still encounter problems while testing the latest version, keeping up-to-date is still important. In this case, ensure that your webshop runs on the latest stable version: PHP 7.4. This is to secure and support your website. 

Updating PHP 8Important aspects to consider when upgrading to PHP 8

It is important that your webshop and all plug-ins can handle this new version. Since PHP 8 has changed a lot in the way code is read. Therfore, not doing so could cause problems. But even if you prefer to wait until PHP 8 is fully compatible with your Magento shop, it is still important to stay up-to-date.

Therefore, here are a few points of attention you can keep in mind when upgrading, regardless of the CMS you use:

  • Make regular backups of your site. This way you always have a fallback basis should something go wrong during the migration or upgrade of your webshop.
  • Always check the results in a test environment before applying the change to the actual site.
  • Check carefully whether all plug-ins support the new version of PHP to which you are upgrading. If this is not the case: upgrade them first or look for alternatives that are compatible with the new version PHP.

 

All in all, staying up-to-date is very important, but it can feel like a big step for many. Do you need help migrating or updating your webshop or do you have any questions, please contact us for advice and assistance. 

About the Author