Now that PHP 7.0 is finally released, it is PHP developers who will decide if they will adopt it in their projects or continue using the previous one.
Read this article to learn about the history of PHP 7, the major new features in this release, the results of a survey conducted in recent weeks to assess the intentions of PHP users to adopt PHP 7, and what to expect for the future of PHP.
The history of PHP 7
PHP 7 is the first major release since PHP 5.0.0 version, which was launched in 2004, for over 11 years.
PHP 6 had an ambitious plan to bring transparent support for the PHP Unicode strings. However, its development has stagnated and PHP 6 was cancelled in 2010.
After that, PHP has had several releases with some important new features such as namespaces in PHP 5.4, but nothing really great to justify the release of a larger version.
In 2010, Facebook announced the PHP HipHop compiler. It was a compiler that would convert PHP code in C ++, which would then be compiled into native machine code with a C ++ compiler. Although the concept is great and it brought some performance improvements for PHP, it was not very practical, because it would take too long to compile PHP scripts to native machine code.
Thereafter, Facebook moved to a different approach. They created the HHVM (HipHop Virtual Machine), which compiles PHP into native machine code using a JIT engine (Just In Time). It would take much less time and still achieved significant performance improvements.
But apparently, Facebook was not happy with the features of PHP and, in 2014, launched Hack, a PHP language derived that brought many features missing in PHP, like most rigorous type checking on all data types and native asynchronous programming support.
Not long after Dmitry Stogov, Zend announced a side project that was a little secret for the development of PHP, which was called PHPNG.
The main new features of PHP 7
Initially, the idea of PHPNG was to investigate the introduction of an IIT engine that would work with the version of the Zend based on PHP. However, with further research, they realized that other improvements could be made in the PHP code to make it run much faster.
PHPNG became the basis for the next PHP version, which was called PHP 7 to avoid confusion with PHP 6, which had cancelled its original plans.
Many other features have been added to PHP 7, including strict type for scalar values, anonymous classes, nested classes, and the ability to compile the PHP and optimize for specific applications, such as WordPress, using Performance Guided Optimization (PGO).
PHP 7.0 was originally meant to be released in October, but as there were still some bugs, the release was delayed until December.
Search result: adoption of PHP 7
PHP 7.0 release is definitely one of the most exciting events in the PHP world in recent times due to many of the resources provided.
Many developers are eager to start using PHP 7, but not all of them will use it immediately. Therefore, a survey was designed to assess the intentions of PHP developers to adopt PHP 7.
Basically, there were three questions:
- Will you use the PHP 7 in production?
- Will you use PHP 7 in your development environment?
- Which is the latest version of PHP that you are using in production?
526 developers responded to the survey, so the results should reflect the reality of the views of many PHP developers.
1. Will you use the PHP 7 in production?
|Yes, I’m already using since the first stable release of 7.0.0
|Yes, I want to start using when the 7.0.0 version is officially released
|Yes, but I’ll wait a few weeks or months once 7.0.0 is released
|It depends on the clients for whom I work
|No, I will not use soon. I need to migrate a lot of code and it will take me a long time
|No, not now, I plan to only use it for future new projects
|No, only if my hosting company force me to use it and not give an older version
2. Will you use PHP 7 in your development environment?
|Yes, I have already used continuously for a while
|Yes, I used a few times to test their features
|Yes, but I want to get started only after the official version 7.0.0 is released
|Yes, but I’ll wait a few weeks or months until I have more time to check out the new version
|It depends on the clients for whom I work
|No, not now, I plan to only use it for future new projects
|No, only if my hosting company force me to use it and I’ll need to fix my code
3. Which is the latest version of PHP that you are using in production?
Analysis of survey results on PHP 7
Since the first research question, we can see that most developers are not early adopters. They want to use PHP 7, but prefer to wait a little until it is more stable.
Although there were eight versions and the suite of PHP tests assessing whether the PHP passes all the tests is quite extensive, developers know there will be incompatible errors or changes, and that will take some time for possible corrections in PHP or the developers codebase happen.
There are also a significant number of developers who will only want to use PHP 7 in new projects, probably because the current projects are very critical and cannot be affected by changes that the new version can cause.
The second question was more curious to understand how developers are on version 7. The results revealed that more developers are interested in testing it in the development environment because it is safe.
If anything breaks the code, you will already have an idea of the amount of work they have to fix, especially if they have their own application test suites ready to see if many fail tests.
The third and final question was to see how they are using updated versions of PHP.
There is a small minority who are bravely already using PHP 7 in production. We do not know if they are using for critical projects, but I believe it is very unlikely.
Well, the good news is that most developers are already using PHP 5.6. In the worst case, there are developers that are still using PHP 5.3, probably because it’s what their hosting company provides or because the latest versions break their code.
But PHP 5.3.11 should be at least the older version that everyone should use, because the most prior to this have serious bugs that can crash the server.
If you are curious, the three developers who said they use other versions of PHP, just a really HHVM said. To use HHVM, you need to control your hosting environment and probably compile it manually. The vast majority of PHP developers have no such possibility or technical capability to do so.
The future of PHP 7
Well, now that the PHP 7 is finally released, you may be wondering what the next step is. There are some features that are already planned, but on others we can only speculate.
Some of the plans for new features have already been discussed in the podcast Lately in PHP. If you are curious, be sure to follow the podcast episodes or subscribe to the YouTube channel to be notified for the latest discussions of PHP features.
PCO is the PDO for Encryption
One thing we already know is that there will be an abstract extension called PCO, it will be like PDO, but for encryption.
Static PHP code analysis
There is also a tool that is being developed by Rasmus Lerdorf called PHAN, which is a static PHP code analyzer. The idea is to detect possible errors just analyzing the PHP code without having to run it. It takes advantage of the new extension AST (Abstract Syntax Tree), which is being introduced in PHP 7.
Asynchronous Programming with Async and Await
Another possibility is that PHP offers better native support for asynchronous programming using async and await commands. These are keywords that allow you to run multiple tasks in parallel in the same script, so you do not have to wait for a run to the other.
Do not confuse asynchronous programming with multi-threaded programming. This is something that PHP’s been using for the pthreads extension.
The biggest advantage of async and await commands is that you no longer have to handle callback. This means that if you need to wait for some asynchronous operation, such as accessing the server file system, database, or remote servers, just use the await keyword that the script will continue at the next statement when the asynchronous operation completes.
The keywords async and await require some non-trivial changes in PHP because it will need to deal with internal event loops. However, the PHP core developers have started to discuss the possibility of implementing the async keywords and commands, because they need to book these keywords before other developers begin to use them.
In addition to language Hack, Facebook also supports async and await. I suspect that Facebook developers can help the PHP core developers at work to bring async and await for PHP.
You can ask to have these commands in PHP is really important. Yes, but you need to understand the advantages.
Apparently, this was a step they took to make more efficient use of server that hosts WordPress.com blogs. We do not know if the WordPress community will embrace this project because there are thousands of plugins that rely on PHP.
Independent Web Server
PHP comes with an independent web server, but not really recommended for production environments.
Once the PHP comes with native support for asynchronous programming, it will be easier to develop HTTP servers even by written in pure PHP as you can do with Node.js
This may make it more flexible in terms of resources and more efficient parallel processing with less memory requests, especially when combined with the asynchronous schedule multi-threaded programming based on pthreads.
PHP 7 was definitely a big giant leap for language. However, the world keeps turning and PHP should follow the new trends, as some have mentioned above.
Still, we should all celebrate and congratulate the developers who gave their time and skill to develop much better PHP as PHP is now 7.
If you liked this article, or want to ask a question about the functionality of PHP 7 and the expectation of adoption, get in touch with us.
If you are looking for Managed WordPress Hosting that is isolated from other users on the server, We provides you with everything for which you have been waiting for. Our hosting is built on a blazing-fast SSD latest hardware That’s Highly tuned for optimum performance. The hosting includes daily backups, anytime money back, 99.97% uptime and 24×7 support.