A Comparison of Different PHP Frameworks
Software product developers need to choose a specific platform before starting a project because it determines the software system’s structure. In order to ascertain the best framework there are various factors that must be considered—beginning with its speed, ending with the importance of its features, and so much more in between. It is during the brainstorming process that development teams decide what framework to use based on what it offers the project. However, determining which is the best is far more complex, which is why developers are always comparing frameworks with each other to make their decision. For instance, Lukasz Kujawa wrote an article on the comparison of PHP frameworks in 2013. Although it is a great article, four years is a considerable amount of time in the IT industry which is why we are writing this article.
The website was used for evaluating the frameworks’ performances. The site has numerous frameworks available for comparison but the author has stopped updating it. However, anyone could still update it themselves if they would want to. One of this article’s main objectives is to determine the improvements of new PHP Frameworks in its production and efficiency. The evaluation was done using PHP for versions 5.6, 7.0, and 7.1.
Materials and Methods
Frameworks for comparison:
14. bluz (the version 7.0.0 for РНР5.6 and the version 7.4 for РНР 7.0 and above)
- Execution Time
- Included files
Testing Machine Specifications
Operation system: Linux Mint 17 Cinnamon 64-bit
Cinnamin Version: 2.2.16
Linux Kernel: 3.13.0-24-generic
Processor: Intel Core i3-4160 CPU 3.60Ghz X 2
Memory: 8 GB Server version: Apache/2.4.7 (ubuntu)
Server build: Jul 15 2016
Other Steps Taken
The command git clone and frame were already installed on our rig but since we used Mint, the settings below had to be done:
net.netfilter.nf_conntrack_max = 100000
net.nf_conntrack_max = 100000
net.ipv4.tcp_max_tw_buckets = 180000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
Information about the structure of php-framework-benchmark: /benchmark – contains bash scripts responsible for gathering information about request quantity per second (by means of ab utility), the amount of information, amount of time spent, and
/benchmark – contains bash scripts responsible for gathering information about request quantity per second (by means of ab utility), the amount of information, amount of time spent, and number of files take from the file “starting point.”
Lib – short for library, the directory where files for processing information obtained
/output – the directory for the results of tests, two files per one file tested—<name>.ab.log and file “name”.output. The former being the log after the ab utility’s work and the latter containing information found in the results.
In order to set the frameworks for this test, there were two methods to choose from.
The bash benchmark.sh. sets frameworks in the file list.sh. which can be edited, added to, or deleted from if necessary. It allows for the user to make a custom configuration which would suit their needs. On the other hand, the bash setup.sh fatfree-3.5/slim-3.0/lumen-5.1/silex-1.3/ allows the user to install separate frameworks by inputting parameters in the command. Although both methods are useful in certain situations, we decided to use the first method because it suited our case better.
It is also made clear that setting the Apache application to browse the folder with the frames is a necessity. The author of the readme file explains it in detail so there is little issue in regard to this.
Results and Discussion
Throughput is the maximum rate at which a device or program can process things. We used the request quantity per second to evaluate how much a specific framework could process in a second. Bearing this in mind, the higher the number of request quantity, the better the application.
Figure 1. Throughput Test Results
*bluz-7.3.1 does not support PHP 5.6
It can be seen in Figure 1 that the phalcon-3.1.2 model performed better than all other models, being followed by the ci-3.0 model in terms of efficiency.
For illustrative purposes, we built graphics for each version of PHP:
Peak Memory Results per Framework
Peak memory refers to the amount of memory the framework needs in order to complete its tasks which means the lower the requirement.
Figure 2. Peak Memory Test Results
|c||Peak Memory (MB)|
|php 5.6||php 7.0||php 7.1|
*bluz-7.3.1 does not support PHP 5.6
In Figure 2, it can be seen that the phalcon-3.1.2 model is the most efficient model in both PHP5.6 and PHP7.1, while evenly matching with model ci-3.0, the second most efficient model, in the PHP7.0 category.
Execution time refers to how long it takes from the system beginning a task until the system producing its results. Naturally, the shorter the time needed to complete a task, the more efficient the system is.
Figure 3. Execution Time Test Results
|Execution time (ms)|
*Bluz7.3.1 does not support PHP5.6
In Figure 3, model ci-3.0 can be seen as the fastest framework, only to be beaten by model slim- 3.0 in PHP7.1.
Included files refers to the number of files that are part of the framework’s file “starting point.” The system spends some time searching for and connecting these files so the fewer files, the better. After the initial startup, however, subsequent launches work with cache to lessen the time needed.
Figure 4. Included Files Test Results
As seen in Figure 4, the phalcon-3.1.2 model has the least number of included files followed by the ci-3.0 model. It can also been seen in Figure 4 that between laravel-5.3 and laravel 5.4, did much better on this test than the later version. The reason behind this being that in laravel-5.3, the file compiled.php could be generated which would cut the number of included files. This feature was removed in laravel-5.4 because the developers thought using opcache for performance tuning would be better.
The data from the results were compared with each other in a way that the performance boosts between PHP versions would be visible.
From PHP5.6 to PHP7.0, the average improvement in performance was almost 90% and from PHP7.0 to PHP7.1, the average improvement was almost 20%.
Laravel 5.3 had the least improvement in the update from PHP 5.6 to PHP 7.0 but it still showed a 33% improvement. Along with the improvement in performance, the update from PHP 5.6 to PHP 7.0 also required 30% less memory to run the applications. The PHP 7.1 update from PHP 7.0 showed the least increase—practically nonexistent—and there were even some models that performed worse after the update such as Symfony and Laravel.
The update to PHP 7.0 from PHP 5.6 showed an average improvement of about 44% and updating to PHP 7.1 after that showed an average improvement of an additional 14%.
In terms of performance, the best framework is the Phalcon, with the CodeIgniter coming in second place performance-wise. However, in general, the CodeIgniter 3 model is the best. But it must not be forgotten that every tool has its purpose—such as a simple framework to be used for simpler applications. If a simple framework were to be used for a detailed, intensive task then it would surely be inefficient. In the same way, using a full-featured framework for simpler tasks would turn the framework redundant and other problems would also be met. This research was done to explain the position of PHP language versions 7.0 and 7.1 for future projects and just as general information for others. The tests confirm the superiority of PHP 7.0 to PHP 5.6, having sped up the processing and reducing the amount of memory required.