The support for PHP 5.6 ends by the end of 2018. A while ago, Magento announced that Magento 1 is still going to be supported (more information here: https://magento.com/blog/magento-news/ongoing-magento-1-support). If it’s not possible for you to migrate to Magento 2 now, perhaps it’s wise to consider changing the PHP version to 7.0.
Is it even worth it?
If you care about a stable and secure environment, you need to take action before the end of the year as PHP 5.6 is going to stop to fulfil these criteria. It’s a perfect moment to move the entire project to Magento 2, which supports PHP 7.0. It might turn out, however, that this step will be too costly or too time-consuming to take. Migrating to M2 is a good opportunity to update the entire store, both the frontend and the business logic of the project. It’s a major operation and there is not that much time untill the end of 2018. In that case, it might be better to update only PHP. Here are a few arguments for this solution:
- Moving from PHP 5.6 to 7.0 shouldn’t be a complicated process, it’s definitely much simpler than migrating from M1 to M2.
- By doing this now, you gain extra months or even years before having to switch to M2.
- Most importantly: PHP 7.0 will speed up your site significantly!
Our customer partcatalog.com decided to work on the efficiency of the site. First, we analyzed the way the site was built and looked for optimization opportunities there: improving scripts, reducing the number of resources loaded, tweaking the backend. It wasn’t possible to fix everything at a small cost and the results achieved – although measurable – were not satisfactory for the customer.
We decided to approach the issue from another angle. Together with the client, we thought about changing the infrastructure of the site. We moved the store to a dedicated Magento hosting by Sonassi. The mechanisms implemented on the server sped up the functioning of the website right away. As the CDN for images, styles, and scripts had been implemented earlier, the last thing to do was to move from PHP 5.6 to PHP 7.0.
How to adjust a Magento 1 store to PHP 7.0
Unfortunately, Magento 1 does not support PHP 7.0 by default. In order to circumvent this, we need to install the extension provided by Inchoo – although officially tested for Magento 1.9.x, it worked for Magento 1.7.x too. This extension fixes all the issues connected with Magento 1 core compatibility. The most problematic thing here might be correcting custom code and 3rd party modules. It’s good to test all the parts of the store thoroughly with this in mind. The official migration manual comes in handy here.
The advantage of PHP 7.0 over PHP 5.6 is indisputable – the effects surpassed our expectations. The page loading time (especially visible on heavily strained product pages) was reduced at least by half. After the changes, everything runs smoothly. Before the optimization work started, an exemplary product page loaded in around 6-8 seconds. After the first stage of code improvement, the gain was hard to notice. Switching to Sonassi decreased the loading time by 1-3 seconds. Once the PHP 7.0 was implemented, the loading time of a product page was eventually reduced to 1-3 seconds in total.
You can find out more about the time results and the number of queries generated by Magento (and more) here: https://www.magecore.com/blog/news/php-7-affects-performance-magento-1-9-ce-vs-magento-2-0-ce
The biggest problems with switching to PHP 7.0 might be caused by compatibility. The Magento core can be adjusted to the newest version, however, there’s no guarantee that additional modules will be compatible too. That’s why it’s crucial to use a staging server (we hope everyone does it) to test each part of the store and make sure it works as expected.
PHP 7.0 & Magento 2
In case of Magento 2, the newest PHP version is practically mandatory. Magento 2 was written with PHP 7.0 in mind from the start. Launching it on an older version means wasting its potential and will result in the store working much more slowly. Since there’s a native support for the newest version, why not use it?
There’s also the newest PHP 7.1 on the horizon. Naturally, it begs the question of whether it’s good to set up the system under this version. If we look at it in terms of efficiency, the gain will be minute. The difference between PHP 7.0 and 7.1 is small. Amasty presented a very good comparison test on their blog: https://blog.amasty.com/magento-1-2-performance-speed-php-5-php-7/.
PHP 7.1 & Magento 2?
Currently, it’s not a recommended combination. Magento 2 uses mcrypt which in PHP 7.1 is marked as deprecated. This might cause errors and it won’t work at all in the future under PHP 7.2. All that’s left is to wait until Magento 2 starts the official support of OpenSSL which will replace mcrypt in PHP.
Wrapping up, we’d like to recommend the following website in case you’re not familiar with it yet: http://php.net/supported-versions.php. It shows the periods of support for specific PHP versions. It’s good to be up-to-date with this and prepared for any changes beforehand.
Speaking of upgrades, we will soon write a bit about moving a project from Magento 1 to Magento 2, so stay tuned and visit our blog!
In case you have any questions, let us know in the comments.