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:
1. slim-3.0
2. ci-3.0
3. lumen-5.1
4. yii-2.0
5. silex-1.3
6. fuel-1.8
7. phpixie-3.2
8. zf-2.5
9. zf-3.0
10. symfony-2.7
11. symfony-3.0
12. laravel-5.3
13. laravel-5.4
14. bluz (the version 7.0.0 for РНР5.6 and the version 7.4 for РНР 7.0 and above)
15. ze-1.0
16. phalcon-3.0
Variables Compared:
- Throughput
- Memory
- 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
php7.1/php7.0/php5.6
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:
# Added
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
sudosysctl –p
Framework Setting
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
php5.6 | php7.0 | php7.1 | |
phalcon-3.1.2 5 | 5058.00 | 5130.00 | 7535.00 |
ci-3.0 | 2943.55 4 | 4116.31 | 4998.05 |
slim-3.0 | 2074.59 | 3143.94 | 3681.00 |
yii-2.0 | 1256.31 | 2276.37 | 2664.61 |
silex-1.3 | 1401.92 | 2263.90 | 2576.22 |
lumen-5.1 1 | 1316.46 | 2384.24 | 2741.81 |
ze-1.0 | 1181.14 | 1989.99 | 1741.81 |
phpixie-3.2 | 898.63 | 1677.15 | 1896.23 |
fuel-1.8 | 1044.77 | 1646.67 | 1770.13 |
bluz-7.3.1 | – * | 1774.00 | 1890.00 |
zf-2.5 | 198.66 | 623.71 | 739.12 |
zf-3.0 | 447.88 | 1012.57 | 1197.26 |
symfony-2.7 | 360.03 | 873.40 | 989.57 |
symfony-3.0 | 372.19 | 853.51 | 1022.28 |
laravel-5.3 2 | 258.62 | 346.25 | 625.99 |
laravel-5.4 | 219.82 | 413.49 | 600.42 |
*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 | |
phalcon-3.1.2 | 0.27 | 0.38 | 0.37 |
ci-3.0 | 0.42 | 0.38 | 0.38 |
slim-3.0 | 0.61 | 0.55 | 0.55 |
yii-2.0 | 1.31 | 0.91 | 0.91 |
silex-1.3 | 0.74 | 0.65 | 0.65 |
lumen-5.1 | 0.80 | 0.63 | 0.63 |
ze-1.0 | 0.79 | 0.56 | 0.56 |
phpixie-3.2 | 1.22 | 0.82 | 0.82 |
fuel-1.8 | 0.70 | 0.60 | 0.60 |
Bluz-7.3.1 | – * | 0.69 | 0.69 |
zf-2.5 | 3.06 | 1.34 | 1.34 |
zf-3.0 | 2.12 | 1.09 | 1.08 |
symfony-2.7 | 3.11 | 1.41 | 1.42 |
symfony-3.0 | 2.86 | 1.30 | 1.32 |
laravel-5.3 | 2.91 | 2.04 | 2.04 |
laravel-5.4 | 3.04 | 1.45 | 1.49 |
*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.
And graphics:
Execution Time
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) | |||
php5.6 | php7.0 | php7.1 | |
phalcon-3.1.2 | 1.300 | 1.470 | 1.080 |
ci-3.0 | 0.996 | 0.818 | 1.007 |
slim-3.0 | 1.530 | 1.228 | 0.662 |
yii-2.0 | 1.478 | 1.410 | 1.639 |
silex-1.3 | 4.657 | 1.625 | 2.681 |
lumen-5.1 | 2.121 | 1.829 | 1.228 |
ze-1.0 | 2.629 | 2.069 | 1.528 |
phpixie-3.2 | 9.329 | 4.757 | 1.911 |
fuel-1.8 | 3.283 | 2.684 | 1.425 |
Bluz-7.3.1 | – * | 1.619 | 1.921 |
zf-2.5 | 22.042 | 5.011 | 3.998 |
zf-3.0 | 12.680 | 2.506 | 2.989 |
symfony-2.7 | 6.529 | 3.902 | 2.384 |
symfony-3.0 | 9.335 | 3.987 | 2.820 |
laravel-5.3 | 19.885 | 4.840 | 2.622 |
laravel-5.4 | 19.561 | 4.758 | 3.940 |
*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
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
Framework | Included files |
phalcon-3.1.2 | 5 |
ci-3.0 | 26 |
slim-3.0 | 53 |
yii-2.0 | 46 |
silex-1.3 | 63 |
lumen-5.1 | 37 |
ze-1.0 | 68 |
phpixie-3.2 | 163 |
fuel-1.8 | 53 |
bluz-7.3.1 | 95 |
zf-2.5 | 222 |
zf-3.0 | 188 |
symfony-2.7 | 110 |
symfony-3.0 | 192 |
laravel-5.3 | 38 |
laravel-5.4 | 176 |
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.
Updating Versions
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%.
Conclusion
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.