Speed up your shop with PHP 7 for Magento

in MagentoPerformance Tags: performancePHP

PHP 7 is the latest version of PHP and available on our Hypernode platform. This article explains how to switch to PHP 7 via your Service Panel and where to find more information about getting your Magento 1 shop working with PHP 7. Magento 2 is fully compatible with PHP 7.

Update 07-08-2017: We now provide the IonCube loader for PHP7. Please contact our support team to enable it.

Why PHP 7?

PHP 7 is the newest PHP version since PHP 5 was released back in 2004. Significant changes since then have been made and it’s safe to say that PHP 7 definitely is a performance booster!

Also: since July 2016 PHP 5.5 is declared end-of-life. Which means the PHP team will no longer release (security) updates.

So in order to be safe, fast and future proof, it’s wise to update to PHP 7.

Magento 1 compatibility

Magento 2 is fully compatible, but Magento 1 doesn’t support PHP 7 by default (Magento 1.9 supports PHP versions up to 5.5.x). Luckily Inchoo created a module which allows you to patch Magento 1 to work on PHP 7. It is very easy to install, follow the instructions below.

IonCube compatibility

We do support IonCube for php7, but this extension is not enabled by default as IonCube is a massive performance killer.
Please contact our support team if you can’t work without it, so we can manually enable it.

We recommend anybody to contact the extension builder instead to provide a non-ioncube-encoded extension rather then activating IonCube. If this is not possible and you have no other choice, please drop us an email so we can enable it for you.

To check if you have IonCube encoded files, use the following command:

$ grep -lr 'if(!extension_loaded('"'"'ionCube Loader'"'"'))' --include='*.php' ~
/data/web/public/includes/src/Mico_Printsize_Model_Reader.php
/data/web/public/includes/src/Mico_Cmp_Model_Observer.php

Keep in mind that IonCube can cause in between 1 and 3 seconds additional load time of your webshop, effectively diminishing all performance optimization you have done on your webshop.

Download and installation

To install the Inchoo php7 extention, first check which magento version you are using.
There are 2 versions of the Inchoo php7 extension:

  • Magento 1.9.2.4 and below (including patch SUPEE-8788): Use the 1.9.2.4 branch.
  • Magento 1.9.3: Use the master branch.

To install, use modman. Use the following command, and replace $BRANCH with the branch you want to use, either “master” or “1.9.2.4”

modman clone https://github.com/Inchoo/Inchoo_PHP7.git -b $BRANCH

So, if you want to use the master branch, the command would be:

modman clone https://github.com/Inchoo/Inchoo_PHP7.git -b master

Don’t forget to flush your caches afterwards:

magerun cache:flush

If you want to automate the installation of plugins you can do this as well using composer. To do this, follow the steps in the Inchoo_PHP7 installation guide.

Test your shop in PHP 7

Switching php versions on hypernode will remove the old version and install the new one. It is therefor not possible to test with 2 php versions on 1 hypernode.

Before switching your PHP version we recommend you to test your shop to see if everything works as it should in the new PHP version. Testing your shop without having your customers notice anything can be done with Vagrant for Hypernode. Vagrant is a tool that gives you the opportunity to set up a virtual staging environment. How you can set up your Vagrant is explained in the article How to use Vagrant as a local staging environment. You can also order a development package to test PHP7.

Testing PHP 7 compatibility

We added php7cc to detect incompatibilities in the php code. This is a very nifty tool to verify whether your code is PHP 7 ready.

For a full list of available functionality, use php7cc --help

Switch to PHP 7 in 5 easy steps

In your Byte Service Panel you can switch to PHP 7 in a few steps:
1. Log on to your Service Panel
2. Select your Hypernode by clicking the app name
3. Go to tab ‘Hypernode’
4. Click the PHP button
5. Choose PHP7

Migrating your Hypernode takes a few minutes.

FAQ

I want to use PHP7 but i need IonCube for dealer4dealer to work

Although we nowadays do support IonCube, we don’t recommend using it, as it causes a massive performance decrease when enabling the IonCube extension.

There now is a newer open source version of the dealer4dealer extension called Xcore which does not need the IonCube plugin to work. Please contact Dealer4Dealer for more information.

How do I get Buckaroo or PostNL to work with PHP 7?

You might get errors using the Buckaroo plugin. Most of the times these errors can be resolved by clearing the wsdl cache.
You can find your PHP WSDL cache files in the /tmp directory:

ls /tmp/wsdl-*

To remove the wsdl cache, remove files starting with wsdl- from your `/tmp

rm /tmp/wsdl-*

If removing the cache files doesn’t work, it can be useful to temporary change the SOAP settings for PHP 7 while debugging. Put the following settings in your .user.ini:

soap.wsdl_cache = 0;
soap.wsdl_cache_enabled = 0;
soap.wsdl_cache_ttl = 0;

Disabling your wdsl cache can cause serious performance problems and should only be temporary to debug php7 issues.

Is PHP 7 the default PHP version on Hypernode?

If you order a Magento 2 hypernode, your php version will by default be set to php7. If you choose a Magento 1 hypernode or if we don’t know your preference, your hypernode will by default run php5.6.

Most shops still use a Magento 1 installation. Although Magento 2 is fully compatible with PHP 7, Magento 1.x versions are not. To avoid incompatibility issues with Magento 1, we automagically select php5.6. You can change the php version for your hypernode from our service panel

Does Varnish work with PHP 7?

The currents stable release of the Turpentine varnish extension is compatible with PHP 7.

For Magento 2 shops there is no Turpentine module, so using your own VCL is the only way to use Varnish. Read more about configuring your own VCL.

Troubleshooting

  • There are some known issues when using the backend with Magento 1.9.2.4 and php version 7.0.6. To avoid these issues, install the dev-master version with composer.
  • Don’t use persistent Redis connections with php7. Make sure the <persistent> setting is empty in your Redis xml files.

2