PHP 7 with OpCache Now Available at Kualo

Written by Jo Stonehouse 0 Comments
php7

We're excited to announce that the latest PHP 7 Release Candidate is now available on our shared and reseller hosting, and also any cloud or dedicated servers which utilise our "Hive" PHP selector. PHP 7 is a big milestone in the development of PHP, and it provides significant improvements in performance over other PHP 5.x versions. In addition to performance increases, there are major changes including depreciated functions and new features. Although most commonly used applications such as WordPress and Drupal are already compatible, if you have any custom-written PHP code on your web site you or your developer may need to make changes to make it compatible; we'll provide some useful details and links later in this post. Given the performance increases, we'd strongly recommend that you ensure your site is compatible sooner rather than later.

What happened to PHP 6?

You may be wondering why there is a jump from PHP 5.6 straight to PHP 7. Where did PHP 6 go? Well, there actually was a version of PHP called PHP 6, and development for it was under way as early as 2005. The project however encountered numerous problems with incorporating unicode without causing serious CPU overhead, and the project was officially abandoned. Since many details and even publications about PHP 6 had already been produced, it was decided that the next major release of PHP would be called PHP 7 to avoid confusion.

PHP 7 is faster than a speeding rocket!

One of the most exciting benefits of PHP 7 is its performance improvements, and the gains that can be realised from simply switching to PHP 7 are huge. The performance gains are so significant that it is worth ensuring your web site is running on PHP 7 as it may mean that your site runs significantly faster, or, if you run a very large site perhaps on a cloud or dedicated server, that it requires less server overhead to run it.

PHP 7 is based on the PHPNG (PHP Next-Gen) Project, which was led by Zend to speed up PHP applications. PHPNG saw speed improvements of between 25% and 70% on real world apps, and since it was incorporated into PHP 7, its performance has more than doubled and will continue to improve as PHP 7 is further developed. To put things into perspective, when PHPNG was published, the WordPress homepage required approximately 9.4 billion CPU instructions to execute. As of now on PHP 7, it requires only 2.6 billion - a 72% improvement.

The following graphs show the performance benefits seen in the current release of PHP 7 for commonly used applications/frameworks.

 

[gallery columns="1" size="large" link="file" ids="1162,1126,1125,1124"]

As you can see, PHP 7 is significantly better at handling requests than PHP 5.6, and this translates into lower latency and faster load times for your application - and faster load times make for happier visitors and improved search engine optimisation.

PHP 7 - OpCache as Standard

Another key component of PHP 7 is that it uses opcode caching as standard. Without OpCache, when PHP code is run it is compiled into opcode and then executed. With OpCache, it is compiled and then the compiled version is stored on disk, so the next time it is run it can skip the compilation step. This means your site will load faster as each request by each visitor for doesn't have to be re-compiled.

We're storing the OpCache in your cPanel user folder, under:

/home/user/.opcache


The cache will refresh in the event a file change is made to the original PHP file, but by storing the cache directly in your home directory, you can also manually clear it at any time by simply deleting the folder or a specific page.  It will then be automatically re-cached next time someone views your site.

PHP 7 and Backwards Compatibility

PHP 7 represents the biggest change in PHP technology since PHP 5.3.  There are many changes that were made and some functions have been deprecated which may result in issues with your applications.  Backwards compatibility with code written for previous versions of PHP is therefore not guaranteed. Most of the major applications and frameworks have already updated their code so that they are PHP 7 compatible, however if you have any custom written applications, you may need to make changes to the code to ensure that it is compatible with PHP 7.

The most significant changes are a new operator, <=>, aptly named the 'Spaceship Operator' due to it's appearance. It can be used for combined comparisons - mostly when dealing with sorting. Secondly, PHP 7 allows developers to define what kind of return type a function is expected to have, whether it be a string, float, int or boolean. If you've got any custom written code that you need to adapt for PHP 7, we'd recommend reviewing the following article from Zend for a bit more information about backward compatibility issues. Another good introduction is found in a 
" target="_blank">presentation by Rasmus Lerdorf, the creator of PHP. This introduction is targeted at developers looking for an in-depth understanding of PHP 7, and as such is very long and highly technical - but if you prefer watching and listening to someone talking through the changes rather than reading lots of documentation, it might be worth checking out.

How to test / enable PHP 7

The easiest way to test whether your site works under PHP 7 is to use our PHP Version Manager in cPanel. You can select the version of PHP that you want to use right down  to the folder level, so if you have some applications that are compatible, and others that are not, provided those applications are stored in different folders, you can select the version of PHP you want to use for each application.

The version we are currently supporting is the latest beta. The final version of PHP 7 is scheduled for release in November, and we will fully support it at that time. We are making the beta available to you so that you can begin testing your site in PHP 7 so that you're able to take advantage of the performance benefits as soon as possible.

PHP 7.0.0 has been officially released and is already available at Kualo.

If you notice anything not functioning as intended, you can always switch back to PHP 5.6 just as simply. If you're using a standard application such as WordPress, provided you're running on the latest version, we'd strongly recommend trying out PHP 7 as the performance benefits are staggering.

PHP 7 can be enabled within cPanel as follows:

1) Log into cPanel.

2) Click the 'PHP Version Manager' icon.

PHP Version Manager

3) Click on the folder name that you wish to change the PHP version for. If you want to change the PHP Version for your entire site, select public_html, otherwise select the sub-folder you want to change the PHP version for.

4) Select 'PHP 7.0.0' from the list of options and click 'Save' at the bottom of the page.



If you encounter any problems, you can easily switch back to the 5.6 branch in the click of a button.

If you have any questions or need assistance enabling this, please visit https://my.kualo.com and log a ticket with our support team. Or if you're looking for great value web hosting with PHP 7 support, head over to our web site and you can sign up today!

You might also like...

About the Author

Jo Stonehouse is the Founder and Managing Director at Kualo. He loves helping businesses succeed online, and is based in London were he lives with his wife, Sali, daughter Seren, son Griff and dog, Milo.