Speed up your shop with PHP 7 for Magento

in MagentoPHP & HHVM 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.

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

Iocube does not support PHP 7 yet (only a very beta version that crashes all the time). We aim at adding an iconcube encoder for PHP7 to our stack as we do for php5, but due to the instability and incompatibility of the current loader, we decided not to add it to our php stack yet.

Check if you have Ioncube encoded files:

$ 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

If you require Ioncube, do not activate PHP 7.

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:

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

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 ‘Overstappen op PHP 7’

Migrating your Hypernode takes a few minutes.

FAQ

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

There is a newer open source version of the dealer4dealer extension called Xcore which does not need the ioncube plugin to work. Please contact linq5 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 your hypernode will default run php5.5.

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. 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.

2