Faster, Safer, More Stable - Joomla and PHP7
Joomla is a CMS based on PHP & MySQL. The popularity and distribution of Joomla was possible because with PHP & MySQL we had found a very friendly and modern basis for the development, 10 years ago and today as well. In this article we want to look at a little history and explain the pros and cons of PHP7 in conjunction with Joomla 3.5.
PHP and Joomla
In the beginning, Joomla 1.0 supported PHP 4.2. The minimum requirement for the PHP version was adjusted with every major version jump. Thus, the development of Joomla was always closely linked to the development of PHP, and its global use at the shared web hosting companies.
This was a simple and very logical reason. With each new version of PHP, you can assume that not only were new functions were introduced, but also speed and stability were improved. PHP 5 brought the support for object-oriented programming, which made it possible for the developers of Joomla to write better code - to name just one example of many. A lot of the new features in PHP also had a direct impact on the security and stability of Joomla.
Improvements in PHP 7
In addition to many functional improvements in PHP 7, the greatest attention has been paid to the execution speed. This is not directly obvious on Joomla websites with few access requests, but after some measurements with Joomla 3.5 Beta 2, the loading time of the complete HTML output was reduced by 10 - 30% on average. This is great for a simple PHP version change in the Control Panel of your web hosting company (if the new PHP version is already offered!).
On high traffic pages the improvement is much more noticeable. For instance, if the web server could handle 100 requests per second with PHP 5.6, then the same web server can handle 200 - 300 requests per second with PHP 7. Especially very complex and computationally intensive extensions for Joomla will benefit significantly from PHP 7.
Joomla had JString as a class since Joomla 1.5. In Joomla 3.3 a Framework package was introduced which had a duplicate class called "string". JString was made to extend the framework string package, as they were just duplicates. "String" is a protected class name in PHP 7, so to avoid a conflict with the PHP 7 class, String was renamed to StringHelper.
This means that if you kept using JString, there is no backwards compatible break, but if you used the framework package directly there was. The problem of this backwards compatibility was accepted since the benefits of PHP 7 far outweigh this disadvantage.
What does it mean for the user?
Many users will not face the question whether they should switch to the new PHP 7 version in the near future, because a lot of the web hosting companies, including the bigger ones, are still only providing PHP 5.5 or 5.6. For web hosts, the provision of a new PHP version incurs costs which the companies try to avoid, so they push it back. It does not hurt to ask your host gently for PHP 7 support, which will make it possible to operate your applications on a modern and fast platform.
A few facts about the PHP versions:
- PHP 5.3 - deprecated - should not be used anymore
- PHP 5.4 - deprecated - should not be used anymore
- PHP 5.5 - security updates provided for further five months
- PHP 5.6 - development support provided for the next 11 months, and afterward will receive security updates for 2 years.
- PHP 7 - supported until the end of 2018
Importance for the extension developers
Anyone who works in code with the reserved word in PHP 7 “String” has to update the code and replace it with “StringHelper”. If the code is not updated, the extension will stop working with Joomla 3.5. This change is easily made, and the effort should be limited.
Note: The problem with the reserved keywords in PHP 7 is not only a Joomla specific problem, but can also occur in other applications.
Give Joomla! 3.5 Beta 2 a try with PHP 7 if you can already use this version under your current hosting contract. The core has been properly tested without any constraints, but some problems in third party extensions have been encountered. In many tested extensions errors were found which blocked the execution completely, or at least PHP errors were displayed but the execution was still performed. We are sure that these issues will be solved once the stable version is released. It is in the interest of the dedicated and active developers to support a modern, fast, efficient and stable base!
Updated: Backwards Compatibility section to clarify issue.
Original article in German
Translated to English by Viktor Vogel
By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/