├── .docker └── apache.dockerfile ├── .github └── workflows │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md ├── base ├── _functions.sh ├── hello_world.sh ├── option_target.sh └── show_fw_array.sh ├── benchmark.sh ├── cakephp-5.1 └── _benchmark │ ├── cakephp │ ├── config │ │ ├── app_local.php │ │ └── routes.php │ ├── src │ │ └── Controller │ │ │ └── HelloWorldController.php │ └── webroot │ │ └── index.php │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── check.sh ├── clean.sh ├── clear-cache.sh ├── codeigniter-4.6 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── codeigniter │ ├── app │ │ ├── Config │ │ │ └── Routes.php │ │ └── Controllers │ │ │ └── HelloWorldController.php │ └── public │ │ └── index.php │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── config ├── docker-apache.sh ├── fastroute-1.3 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── public │ └── index.php ├── fatfree-3.9 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── public │ └── index.php ├── index.php ├── kumbia-1.2 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── kumbia │ └── default │ │ ├── app │ │ └── controllers │ │ │ └── hello_controller.php │ │ └── public │ │ └── index.php │ ├── setup.sh │ └── update.sh ├── laravel-10.3 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── laravel │ ├── app │ │ └── Http │ │ │ └── Controllers │ │ │ └── HelloWorldController.php │ ├── public │ │ └── index.php │ └── routes │ │ └── web.php │ ├── setup.sh │ └── update.sh ├── laravel-11.0 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── laravel │ ├── app │ │ └── Http │ │ │ └── Controllers │ │ │ └── HelloWorldController.php │ ├── public │ │ └── index.php │ └── routes │ │ └── web.php │ ├── setup.sh │ └── update.sh ├── leaf-3.11 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── public │ └── index.php ├── libs ├── app.js ├── avg_ms.php ├── build_table.php ├── chart4.3.js ├── output_data.php ├── parse_results.php ├── php_config.php ├── recalc_relative.php ├── reset_opcache.php ├── show_results_table.php ├── strreplace.php ├── sum_ms.php └── trim.php ├── lumen-10.0 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── lumen │ ├── app │ │ └── Http │ │ │ └── Controllers │ │ │ └── HelloWorldController.php │ ├── public │ │ └── index.php │ └── routes │ │ └── web.php │ ├── setup.sh │ └── update.sh ├── phroute-2.2 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── public │ └── index.php ├── pure-php ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh └── public │ └── index.php ├── results.sh ├── screenshots ├── ethereum.jpg ├── php-frameworks-bench-exectime.png ├── php-frameworks-bench-includedfiles.png ├── php-frameworks-bench-memory.png └── php-frameworks-bench-throughput.png ├── setup.sh ├── silex-2.3 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── web │ └── index.php ├── slim-4.13 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── public │ └── index.php ├── slim-4.14 ├── Controllers │ └── HelloWorldController.php ├── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ └── update.sh ├── composer.json └── public │ └── index.php ├── symfony-5.4 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ ├── symfony │ ├── config │ │ └── routes.yaml │ ├── public │ │ └── index.php │ └── src │ │ └── Controller │ │ └── HelloWorldController.php │ └── update.sh ├── symfony-6.4 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ ├── symfony │ ├── config │ │ └── routes.yaml │ ├── public │ │ └── index.php │ └── src │ │ └── Controller │ │ └── HelloWorldController.php │ └── update.sh ├── symfony-7.0 └── _benchmark │ ├── clean.sh │ ├── clear-cache.sh │ ├── hello_world.sh │ ├── setup.sh │ ├── symfony │ ├── config │ │ └── routes.yaml │ ├── public │ │ └── index.php │ └── src │ │ └── Controller │ │ └── HelloWorldController.php │ └── update.sh ├── update.sh └── yii-2.0-basic └── _benchmark ├── clean.sh ├── hello_world.sh ├── setup.sh ├── update.sh └── yii2 ├── controllers └── HelloController.php └── web └── index.php /.docker/apache.dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.4-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y libicu-dev 5 | 6 | RUN mkdir /var/www/html/PHP-Frameworks-Bench 7 | 8 | # Need it in a lot of frameworks 9 | RUN docker-php-ext-install intl 10 | 11 | # Optional opcache (recommended) 12 | #RUN docker-php-ext-install opcache 13 | 14 | ENV PORT 80 15 | ENTRYPOINT [] 16 | CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground 17 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test PHP benchmark 2 | on: [ push, pull_request ] 3 | 4 | jobs: 5 | setup: 6 | name: Check PHP frameworks 7 | runs-on: ubuntu-24.04 8 | 9 | steps: 10 | 11 | - uses: actions/checkout@v4 12 | 13 | - name: Install WRK 14 | run: sudo apt-get install wrk w3m 15 | 16 | - name: Setup PHP 17 | uses: shivammathur/setup-php@v2 18 | with: 19 | php-version: 8.4 20 | extensions: dom, curl, libxml, mbstring, zip, pcntl, ctype, iconv, intl 21 | coverage: none 22 | 23 | - name: Install Apache mod_php 24 | run: | 25 | LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu 26 | sudo apt install libapache2-mod-php8.4 27 | sudo a2enmod php8.4 rewrite 28 | shell: bash 29 | 30 | - name: Setup frameworks 31 | run: bash setup.sh 32 | 33 | - name: Copy files to web root 34 | run: | 35 | sudo mkdir /var/www/html/PHP-Frameworks-Bench 36 | sudo cp -R ./* /var/www/html/PHP-Frameworks-Bench/ 37 | sudo chown -R www-data:www-data /var/www/html 38 | 39 | - name: Restart apache server 40 | run: sudo service apache2 restart 41 | 42 | - name: Check frameworks 43 | run: bash check.sh 44 | 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /output/* 2 | vendor/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP Frameworks Bench 2 | [![Test PHP benchmark](https://github.com/myaaghubi/PHP-Frameworks-Bench/actions/workflows/test.yml/badge.svg)](https://github.com/myaaghubi/PHP-Frameworks-Bench/actions/workflows/test.yml) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/myaaghubi/PHP-Frameworks-Bench?color=purpol) ![GitHub](https://img.shields.io/github/license/myaaghubi/PHP-Frameworks-Bench?color=green) 3 | 4 | 5 | 📊 This project attempts to measure the minimum overhead (minimum bootstrap cost) of PHP frameworks in the real world. 6 | 7 | So I think the minimum should not include: 8 | 9 | * cost of template engine 10 | * cost of database manipulation 11 | * cost of debugging information 12 | 13 | Benchmarking on components like template engines or ORM/Database libraries is out of the scope of this project. 14 | 15 | 16 | - [PHP Frameworks Bench](#php-frameworks-bench) 17 | - [Benchmarks](#benchmarks) 18 | - [Latest](#latest) 19 | - [OPCache On/Off](#opcache-on) 20 | - [How to Benchmark](#how-to-benchmark) 21 | - [Docker](#docker) 22 | - [Commands](#commands) 23 | - [Benchmarking Policy](#benchmarking-policy) 24 | - [Add Your Framework](#add-your-framework) 25 | - [Donate](#-donate) 26 | - [References](#references) 27 | - [License](#license) 28 | 29 | 30 | ## Benchmarks 31 | 32 | ### Latest 33 | 34 | #### Environment 35 | 36 | For `PHP 8.3` check out [this link](https://github.com/myaaghubi/PHP-Frameworks-Bench/tree/92cce05b3f6cf0aa33a06c3f13d8dd0c706f3b6c). 37 | 38 | For `PHP 8.2` check out [this link](https://github.com/myaaghubi/PHP-Frameworks-Bench/tree/163d2c0eb7862cf3c14479913435cb90ec7d6f0b). 39 | 40 | * Ubuntu 24.04 LTS x86_64 41 | * PHP 8.4.3 42 | * OPCache Off 43 | * Apache 2.4.58 44 | * WRK 4.2.0 (5 min) 45 | * CPU Core i7-3770K/4.4Ghz 46 | * Memory 16G 47 | 48 | 49 | #### Results (2025/2/7) 50 | 51 | These are my benchmarks, not yours. **I encourage you to run on your -production equivalent- environments.** 52 | 53 | ![Frameworks Benchmark Results Graph Throughput](screenshots/php-frameworks-bench-throughput.png) 54 | ![Frameworks Benchmark Results Graph Memory](screenshots/php-frameworks-bench-memory.png) 55 | ![Frameworks Benchmark Results Graph Execution Time](screenshots/php-frameworks-bench-exectime.png) 56 | ![Frameworks Benchmark Results Graph Included Files](screenshots/php-frameworks-bench-includedfiles.png) 57 | 58 | |framework |requests per second (rps)|relative (rps)|peak memory|relative (mem)| 59 | |-------------------|------------------------:|-------------:|----------:|-------------:| 60 | |pure-php | 25,833.28| 409.4| 0.42| 1.0| 61 | |kumbia-1.2 | 5,681.12| 90.0| 0.54| 1.3| 62 | |fastroute-1.3 | 4,262.94| 67.6| 0.56| 1.3| 63 | |phroute-2.2 | 3,949.48| 62.6| 0.58| 1.4| 64 | |fatfree-3.9 | 1,364.24| 21.6| 1.72| 4.1| 65 | |leaf-3.11 | 1,298.60| 20.6| 1.18| 2.8| 66 | |slim-4.14 | 741.19| 11.7| 1.59| 3.8| 67 | |yii-2.0-basic | 527.72| 8.4| 2.60| 6.2| 68 | |silex-2.3 | 512.44| 8.1| 2.28| 5.4| 69 | |lumen-10.0 | 301.01| 4.8| 3.78| 9.0| 70 | |symfony-5.4 | 281.95| 4.5| 3.84| 9.1| 71 | |codeigniter-4.6 | 274.93| 4.4| 3.93| 9.4| 72 | |symfony-7.0 | 261.52| 4.1| 4.20| 10.0| 73 | |symfony-6.4 | 254.35| 4.0| 4.26| 10.1| 74 | |cakephp-5.1 | 222.48| 3.5| 4.96| 11.8| 75 | |laravel-10.3 | 76.35| 1.2| 13.82| 32.9| 76 | |laravel-11.0 | 63.10| 1.0| 16.19| 38.5| 77 | 78 | 79 | #### OPCache On 80 | Check out the video for more information. 81 | 82 | [![Results with OPCache On/Off & How to add your framework](http://img.youtube.com/vi/Dk8YHQZ6jfY/0.jpg)](http://www.youtube.com/watch?v=Dk8YHQZ6jfY) 83 | 84 | 85 | ## How to Benchmark 86 | 87 | If you want to have benchmarks on `PHP extension frameworks` like `Phalcon`, you need to install the extension first, based on its own documentation. 88 | 89 | 1- Download & Setup: 90 | 91 | ```bash 92 | # make sure to put it in the root of your web path 93 | $ git clone https://github.com/myaaghubi/PHP-Frameworks-Bench.git 94 | 95 | $ cd PHP-Frameworks-Bench 96 | 97 | # optional 98 | $ nano config 99 | 100 | # run the setup & follow the progress 101 | $ yes | bash setup.sh 102 | ``` 103 | 104 | 2- Make sure everything is ok: 105 | 106 | ```bash 107 | $ bash check.sh 108 | # bash check.sh -t pure-php 109 | # ✔ pure-php 110 | ``` 111 | 112 | 3- Run benchmarks: 113 | 114 | ```bash 115 | # bash benchmark.sh --help 116 | $ bash benchmark.sh 117 | ``` 118 | 119 | 4- Check the results: 120 | - web: 121 | 122 | 123 | 124 | - terminal: 125 | ```bash 126 | # bash results.sh --help 127 | bash results.sh 128 | ``` 129 | 130 | 131 | ## Docker 132 | 133 | Results with docker may or may not be reliable but in a situation you can use it like: 134 | 135 | 1- Change the `base` in `config` on the right port(`8080` considered): 136 | 137 | ```ini 138 | base="http://127.0.0.1:8080/PHP-Frameworks-Bench" 139 | ... 140 | ``` 141 | 142 | 2- Run/download the docker: 143 | 144 | ```bash 145 | $ bash docker-apache.sh 146 | ``` 147 | 148 | 3- Run the benchmark: 149 | 150 | ```bash 151 | # run it in another terminal 152 | $ bash benchmark.sh 153 | ``` 154 | 155 | 156 | ## Commands 157 | 158 | ```bash 159 | # use bash benchmark.sh --help 160 | $ bash benchmark.sh -f -rapache -t pure-php 161 | 162 | # run composer update for frameworks 163 | $ bash update.sh 164 | 165 | # to clean them all 166 | # trouble? run it then 167 | # you can use `bash setup.sh` again 168 | $ bash clean.sh 169 | 170 | # clear the cache of frameworks 171 | $ bash clear-cache.sh 172 | 173 | # show the results table 174 | $ bash results.sh 175 | ``` 176 | 177 | To specify frameworks, put them with `-t ...` after each command: 178 | 179 | ```bash 180 | # supported for `setup.sh`, `benchmark.sh`, `update.sh`, `clean.sh`, and `clear-cache.sh` 181 | # bash benchmarks.sh --help 182 | $ bash benchmark.sh -t laravel-10.2/ slim-4.12/ ... 183 | ... 184 | ``` 185 | 186 | 187 | ## Add Your Framework 188 | Check out the [Benchmarking Policy](#benchmarking-policy), to get more information watch the video [OPCache On/Off](#opcache-on). 189 | 190 | 191 | ## Benchmarking Policy 192 | 193 | * Use `composer` to install frameworks according to their official documentation. 194 | * Use the default configuration. 195 | * Minimum changes on frameworks to have benchmarks. 196 | * Don't remove any components/configurations even if there is no use for them. 197 | * Include a `controller` class to get the `Hello World!` for each, based on the default template of each framework for `controllers`. 198 | * Turn off the `debug` mode and set the environment to `production` mode. 199 | * General optimization for the production environment, like `--optimize-autoloader` for the `composer`. 200 | 201 | Some frameworks are optimized more than others, so some developers may think using default configuration is not fair. The dept of optimizing a framework depends on the skills/experiences of the developer too, so it's the rabbit hole and nonsense for ranking. Please **note** optimizing for the `Hello World` is not acceptable! Building the fastest `Hello World` application is not the goal of this project. I think the default configuration of frameworks is a good starting point to have a ranking. 202 | 203 | If you find something wrong in my code, feel free to send a `PR`. 204 | 205 | 206 | ## 🍔 Donate 207 | Don't forget to donate if you find it useful ☕ 🍺 🍸 🍔 208 | 209 | ETH: 0x0ADd51D6855d2DF11BB5F331A3fa345c67a863b2 210 | 211 | ![Ethereum](screenshots/ethereum.jpg?raw=true "Ethereum") 212 | 213 | 214 | ## References 215 | Note: This project is based on 216 | [php-framework-benchmark](https://github.com/kenjis/php-framework-benchmark), thanks to [Kenjis](https://github.com/kenjis). It is very old and abandoned, so I decided to split it from the origin and change/update it separately. 217 | 218 | 🙏 Thanks to contributors: 219 | 220 | - [Joan Miquel](https://github.com/joanhey) 221 | 222 | - [Rostunov Sergey](https://github.com/stdex) 223 | 224 | 225 | 226 | 📄 For frameworks, I considered the official repos: 227 | * [CakePHP](https://github.com/cakephp/cakephp) 228 | * [CodeIgniter](https://github.com/codeigniter4/CodeIgniter4) 229 | * [FastRoute](https://github.com/nikic/FastRoute) 230 | * [FatFree](https://github.com/bcosca/fatfree) 231 | * [FuelPHP](https://github.com/fuelphp/fuelphp) 232 | * [KumbiaPHP](https://github.com/KumbiaPHP/KumbiaPHP) 233 | * [Laminas](https://github.com/laminas) 234 | * [Laravel](https://github.com/laravel/laravel) 235 | * [Leaf](https://github.com/leafsphp/leaf) 236 | * [Lumen](https://github.com/laravel/lumen) 237 | * [PhRoute](https://github.com/mrjgreen/phroute) 238 | * [Silex](https://github.com/silexphp/Silex) 239 | * [Slim](https://github.com/slimphp/Slim) 240 | * [Symfony](https://github.com/symfony/symfony) 241 | * [Ubiquity](https://github.com/phpMv/ubiquity) 242 | * [Yii](https://github.com/yiisoft/yii2) 243 | 244 | 245 | ## License 246 | 247 | You are allowed to use this plugin/project under the terms of the GNU General Public License version 2. 248 | 249 | Copyright (C) 2025 [Mohammad Yaaghubi](https://github.com/myaaghubi) 250 | -------------------------------------------------------------------------------- /base/_functions.sh: -------------------------------------------------------------------------------- 1 | benchmark () { 2 | fw="$1" 3 | url="$2" 4 | output_wrk="output/$dir_datetime/$fw.wrk.log" 5 | output="output/$dir_datetime/$fw.output" 6 | 7 | # check out the appropriate response is reachable 8 | url_status=$(bash check.sh -t "$fw") 9 | 10 | # find 'done' 11 | status=${url_status%%✔ ${fw}*} 12 | 13 | # if the index of 'done' be equal to 14 | # the length of the url_status then 15 | # the appropriate output (Hello World! ...) not reachable 16 | # and there is no point to run the benchmark 17 | if [ ${#status} -eq ${#url_status} ]; then 18 | echo "Error! $fw: Hello World! ... not reachable" 19 | echo "$fw: 0: 0: 0: 0" >> "$results_file" 20 | return 1 21 | fi 22 | 23 | config_wrk="wrk -t${threads} -c${connections} -d${duration}s" 24 | 25 | # is it wsl!? 26 | # if you're using wsl, it's necessary to put -R (--rate) 27 | # in this version of wrk 28 | # I used a large number to make sure there be no limitation of rate 29 | # for a high end server, you can increase first two parameters 30 | if grep -q Microsoft /proc/version; then 31 | config_wrk="$config_wrk -R1000g $url" 32 | else 33 | config_wrk="$config_wrk $url" 34 | fi 35 | 36 | echo $config_wrk 37 | 38 | config_wrk="$config_wrk '$url' > '$output_wrk'" 39 | eval $config_wrk 40 | 41 | rps=`grep "Requests/sec:" "$output_wrk" | tr -cd '0-9.'` 42 | 43 | echo "rps: $rps" 44 | 45 | # to make a small gap between the WRK and CURL 46 | sleep 1 47 | 48 | count=5 49 | total=0 50 | i=0 51 | # The for (( expr ; expr ; expr )) syntax is not available in sh, so: 52 | while [ $i -lt $count ] 53 | do 54 | curl -sS "$url" > "$output" 55 | t=`tail -1 "$output" | cut -f 2 -d ':'` 56 | total=`php ./libs/sum_ms.php $t $total` 57 | i=$(( $i + 1 )) 58 | done 59 | time=`php ./libs/avg_ms.php $total $count` 60 | 61 | 62 | # get memory and file 63 | memory=`tail -1 "$output" | cut -f 1 -d ':'` 64 | file=`tail -1 "$output" | cut -f 3 -d ':'` 65 | 66 | echo "$fw: $rps: $memory: $time: $file" >> "$results_file" 67 | 68 | echo "$fw" >> "$check_file" 69 | grep "Document Length:" "$output_wrk" >> "$check_file" 70 | grep "Failed requests:" "$output_wrk" >> "$check_file" 71 | grep 'Hello World!' "$output" >> "$check_file" 72 | 73 | # check errors 74 | touch "$error_file" 75 | error='' 76 | x=`grep 'Failed requests: 0' "$output_wrk"` 77 | if [ "$x" = "" ]; then 78 | tmp=`grep "Failed requests:" "$output_wrk"` 79 | error="$error$tmp" 80 | fi 81 | x=`grep 'Hello World!' "$output"` 82 | if [ "$x" = "" ]; then 83 | tmp=`cat "$output"` 84 | error="$error$tmp" 85 | fi 86 | if [ "$error" != "" ]; then 87 | echo -e "$fw\n$error" >> "$error_file" 88 | echo "---" >> "$error_file" 89 | fi 90 | 91 | echo "$url" >> "$url_file" 92 | } 93 | -------------------------------------------------------------------------------- /base/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd `dirname $0` 4 | . ./_functions.sh 5 | . ../config 6 | 7 | bn_name=`basename $0 .sh` 8 | 9 | cd .. 10 | 11 | mkdir -p output 12 | 13 | export dir_datetime=`date +%y-%m-%dT%H-%M-%S` 14 | mkdir output/$dir_datetime 15 | 16 | results_file="output/$dir_datetime/results.log" 17 | check_file="output/$dir_datetime/check.log" 18 | error_file="output/$dir_datetime/error.log" 19 | url_file="output/$dir_datetime/urls.log" 20 | 21 | phpc=`curl -s "$base/libs/php_config.php"` 22 | echo "/------- PHP Config -------/" 23 | echo "$phpc" 24 | 25 | # Colors 26 | GREEN='\033[0;32m' 27 | RED='\033[0;31m' 28 | NC='\033[0m' # No Color 29 | 30 | for fw in `echo $param_targets` 31 | do 32 | echo "\n/------- $fw -------/" 33 | if [ -d "$fw" ]; then 34 | 35 | # read -p "Continue to $fw (y/n)?" choice 36 | # case "$choice" in 37 | # y|Y ) echo "yes";; 38 | # n|N ) echo "no";; 39 | # * ) echo "invalid";; 40 | # esac 41 | # if [ "$choice" = "n" ] || [ "$choice" = "N" ]; then 42 | # continue 43 | # fi 44 | 45 | if [ "$param_fresh" = true ]; then 46 | bash clean.sh 47 | bash setup.sh -t "$fw" 48 | fi 49 | 50 | # read -p "Continue to benchmark (y/n)?" choice 51 | # case "$choice" in 52 | # y|Y ) echo "yes";; 53 | # * ) echo "invalid";; 54 | # esac 55 | # if [ "$choice" = "n" ] || [ "$choice" = "N" ]; then 56 | # continue 57 | # fi 58 | 59 | # reset the opcache 60 | opcacherest=`curl -s "$base/libs/reset_opcache.php"` 61 | echo "$opcacherest" 62 | 63 | if [ "$param_restart_apache" = true ]; then 64 | echo 'systemctl restart apache2' 65 | sudo systemctl restart apache2 66 | fi 67 | 68 | if [ "$param_restart_nginx" = true ]; then 69 | echo 'systemctl restart nginx' 70 | sudo systemctl restart nginx 71 | fi 72 | 73 | # a small gap between composer, reset_opcache, webserver restarted and benchmark 74 | sleep 2 75 | 76 | # get the hello world link 77 | . "$fw/_benchmark/hello_world.sh" 78 | 79 | echo "/------- $fw: benchmarking -------/" 80 | 81 | # run the benchmark 82 | benchmark "$fw" "$url" 83 | else 84 | # check for dir 85 | echo "${RED}Dir $fw/ doesn't exist!${NC}" 86 | FAIL=1 87 | fi 88 | done 89 | 90 | cat "$error_file" 91 | -------------------------------------------------------------------------------- /base/option_target.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! `which php` ]; then 4 | echo "php not found." 5 | exit 1; 6 | fi 7 | 8 | function showHelp() 9 | { 10 | cat << HEREDOC 11 | 12 | Usage: bash check.sh [-t pure-php slim-*] 13 | 14 | Optional Arguments: 15 | -h, --help Show this help message and exit 16 | -t, --target Specify your target framework/s for benchmarking 17 | Separate them via space. 18 | 19 | HEREDOC 20 | } 21 | 22 | export param_targets="$frameworks_list" 23 | 24 | oldIFS="$IFS" 25 | paramsin="${@%/}" 26 | IFS='()' 27 | # ${paramsin%%*( )} not a good idea 28 | paramsin=(`php ./libs/trim.php "r" "${paramsin}"`) 29 | IFS=';' 30 | params=(`php ./libs/strreplace.php " -" ";-" " ${paramsin}"`) 31 | IFS=$oldIFS 32 | 33 | init_benchmark=true 34 | for option in "${params[@]}" 35 | do 36 | case "$option" in 37 | -t*|--target*) 38 | arg_=${option//--target /} 39 | arg_=${arg_//-t /} 40 | if [ ${#arg_} -ge 5 ]; then 41 | param_targets="$arg_" 42 | fi 43 | ;; 44 | -h|--help) 45 | init_benchmark=false 46 | showHelp; 47 | ;; 48 | ""|" ") 49 | ;; 50 | *) 51 | init_benchmark=false 52 | echo "\"${option}\" not available" 53 | exit 1 54 | ;; 55 | esac 56 | done 57 | 58 | if [ "$init_benchmark" = false ]; then 59 | exit 1 60 | fi -------------------------------------------------------------------------------- /base/show_fw_array.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd `dirname $0` 4 | cd .. 5 | 6 | . ../config 7 | 8 | # include framework list 9 | targets="$frameworks_list" 10 | 11 | echo '[' 12 | 13 | for fw in $targets 14 | do 15 | if [ -d "$fw" ]; then 16 | echo "\t'$fw'," 17 | fi 18 | done 19 | 20 | echo ']' 21 | -------------------------------------------------------------------------------- /benchmark.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! `which php` ]; then 4 | echo "php not found." 5 | exit 1; 6 | fi 7 | 8 | if [ ! `which wrk` ]; then 9 | echo "WRK not found." 10 | exit 1; 11 | fi 12 | 13 | if [ ! `which curl` ]; then 14 | echo "CURL not found." 15 | exit 1; 16 | fi 17 | 18 | . ./config 19 | 20 | function showHelp() 21 | { 22 | cat << HEREDOC 23 | 24 | Usage: bash benchmark.sh [-f] [-rapache] [-t pure-php slim] 25 | 26 | Optional Arguments: 27 | -f, --fresh Clean all frameworks and install the target framework -fresh install- before benchmark. 28 | -h, --help Show this help message and exit 29 | -rapache, --restart-apache Restart apache "sudo systemctl restart apache2" before each benchmark. 30 | -rnginx, --restart-nginx Restart apache "sudo systemctl restart nginx" before each benchmark. 31 | -t, --target Specify your target framework/s for benchmarking 32 | Separate them via space. 33 | 34 | HEREDOC 35 | } 36 | 37 | export param_targets="$frameworks_list" 38 | export param_fresh=false 39 | export param_restart_apache=false 40 | export param_restart_nginx=false 41 | 42 | oldIFS="$IFS" 43 | paramsin="${@%/}" 44 | IFS='()' 45 | # ${paramsin%%*( )} not a good idea 46 | paramsin=(`php ./libs/trim.php "r" "${paramsin}"`) 47 | IFS=';' 48 | params=(`php ./libs/strreplace.php " -" ";-" " ${paramsin}"`) 49 | IFS=$oldIFS 50 | 51 | init_benchmark=true 52 | for option in "${params[@]}" 53 | do 54 | case "$option" in 55 | -f|--fresh) 56 | param_fresh=true 57 | ;; 58 | -rapache|--restart-apache) 59 | param_restart_apache=true 60 | ;; 61 | -rnginx|--restart-nginx) 62 | param_restart_nginx=true 63 | ;; 64 | -t*|--target*) 65 | arg_=${option//--target /} 66 | arg_=${arg_//-t /} 67 | if [ ${#arg_} -ge 5 ]; then 68 | param_targets="$arg_" 69 | fi 70 | ;; 71 | -h|--help) 72 | init_benchmark=false 73 | showHelp; 74 | ;; 75 | ""|" ") 76 | ;; 77 | *) 78 | init_benchmark=false 79 | echo "\"${option}\" not available" 80 | exit 1 81 | ;; 82 | esac 83 | done 84 | 85 | if [ "$init_benchmark" = true ]; then 86 | sh ./base/hello_world.sh 87 | echo '' 88 | bash results.sh 89 | fi -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/cakephp/config/app_local.php: -------------------------------------------------------------------------------- 1 | false, 20 | 21 | /* 22 | * Security and encryption configuration 23 | * 24 | * - salt - A random string used in security hashing methods. 25 | * The salt value is also used as the encryption key. 26 | * You should treat it as extremely sensitive data. 27 | */ 28 | 'Security' => [ 29 | 'salt' => env('SECURITY_SALT', '__SALT__'), 30 | ], 31 | 32 | /* 33 | * Connection information used by the ORM to connect 34 | * to your application's datastores. 35 | * 36 | * See app.php for more configuration options. 37 | */ 38 | 'Datasources' => [ 39 | 'default' => [ 40 | 'host' => 'localhost', 41 | /* 42 | * CakePHP will use the default DB port based on the driver selected 43 | * MySQL on MAMP uses port 8889, MAMP users will want to uncomment 44 | * the following line and set the port accordingly 45 | */ 46 | //'port' => 'non_standard_port_number', 47 | 48 | 'username' => 'my_app', 49 | 'password' => 'secret', 50 | 51 | 'database' => 'my_app', 52 | /* 53 | * If not using the default 'public' schema with the PostgreSQL driver 54 | * set it here. 55 | */ 56 | //'schema' => 'myapp', 57 | 58 | /* 59 | * You can use a DSN string to set the entire configuration 60 | */ 61 | 'url' => env('DATABASE_URL', null), 62 | ], 63 | 64 | /* 65 | * The test connection is used during the test suite. 66 | */ 67 | 'test' => [ 68 | 'host' => 'localhost', 69 | //'port' => 'non_standard_port_number', 70 | 'username' => 'my_app', 71 | 'password' => 'secret', 72 | 'database' => 'test_myapp', 73 | //'schema' => 'myapp', 74 | 'url' => env('DATABASE_TEST_URL', 'sqlite://127.0.0.1/tests.sqlite'), 75 | ], 76 | ], 77 | 78 | /* 79 | * Email configuration. 80 | * 81 | * Host and credential configuration in case you are using SmtpTransport 82 | * 83 | * See app.php for more configuration options. 84 | */ 85 | 'EmailTransport' => [ 86 | 'default' => [ 87 | 'host' => 'localhost', 88 | 'port' => 25, 89 | 'username' => null, 90 | 'password' => null, 91 | 'client' => null, 92 | 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), 93 | ], 94 | ], 95 | ]; 96 | -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/cakephp/config/routes.php: -------------------------------------------------------------------------------- 1 | setRouteClass(DashedRoute::class); 46 | 47 | /* *** PHP-Frameworks-Bench *** */ 48 | $routes->connect('/hello/index', ['controller' => 'HelloWorld', 'action' => 'display', 'home']); 49 | 50 | $routes->scope('/', function (RouteBuilder $builder) { 51 | /* 52 | * Here, we are connecting '/' (base path) to a controller called 'Pages', 53 | * its action called 'display', and we pass a param to select the view file 54 | * to use (in this case, templates/Pages/home.php)... 55 | */ 56 | $builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']); 57 | 58 | /* 59 | * ...and connect the rest of 'Pages' controller's URLs. 60 | */ 61 | $builder->connect('/pages/*', 'Pages::display'); 62 | 63 | /* 64 | * Connect catchall routes for all controllers. 65 | * 66 | * The `fallbacks` method is a shortcut for 67 | * 68 | * ``` 69 | * $builder->connect('/:controller', ['action' => 'index']); 70 | * $builder->connect('/:controller/:action/*', []); 71 | * ``` 72 | * 73 | * You can remove these routes once you've connected the 74 | * routes you want in your application. 75 | */ 76 | $builder->fallbacks(); 77 | }); 78 | 79 | /* 80 | * If you need a different set of middleware or none at all, 81 | * open new scope and define routes there. 82 | * 83 | * ``` 84 | * $routes->scope('/api', function (RouteBuilder $builder) { 85 | * // No $builder->applyMiddleware() here. 86 | * 87 | * // Parse specified extensions from URLs 88 | * // $builder->setExtensions(['json', 'xml']); 89 | * 90 | * // Connect API actions here. 91 | * }); 92 | * ``` 93 | */ 94 | }; 95 | -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/cakephp/src/Controller/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | response->withStringBody('Hello World!'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/cakephp/webroot/index.php: -------------------------------------------------------------------------------- 1 | emit($server->run()); 38 | 39 | /* *** PHP-Frameworks-Bench *** */ 40 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf !("_benchmark") 3 | find -path './.*' -delete 4 | rm -rf _benchmark/temp -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # clear cache 3 | bin/cake cache clear_all 4 | echo -e "done" -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | url="$base/$fw/webroot/index.php/hello/index" -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # create project 3 | rm -rf _benchmark/temp 4 | composer create-project --prefer-dist cakephp/app:5.1.* ./_benchmark/temp --ansi 5 | yes|mv ./_benchmark/temp/{.,}* ./ 6 | 7 | # have the route & controller 8 | yes|cp -r _benchmark/cakephp/* ./ 9 | 10 | # some enhancements 11 | composer dump-autoload -o 12 | composer install --no-interaction --no-dev -o --ansi 13 | rm ./webroot/.htaccess -------------------------------------------------------------------------------- /cakephp-5.1/_benchmark/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer update 3 | 4 | # have the route & controller 5 | yes|cp -r _benchmark/cakephp/* ./ 6 | 7 | # some enhancements 8 | composer dump-autoload -o 9 | composer install --no-interaction --no-dev -o 10 | rm ./webroot/.htaccess -------------------------------------------------------------------------------- /check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./config 4 | . ./base/option_target.sh 5 | 6 | # Colors 7 | GREEN='\033[0;32m' 8 | RED='\033[0;31m' 9 | NC='\033[0m' # No Color 10 | 11 | FAIL=0 12 | 13 | for fw in `echo $param_targets` 14 | do 15 | if [ -d "$fw" ]; then 16 | . "$fw/_benchmark/hello_world.sh" 17 | 18 | url_output=$(curl -s "$url") 19 | 20 | # expected to get the Hello World! + libs/output_data.php 21 | if ! [[ "$url_output" =~ ^('Hello World!')(.*)(([0-9]*):(([0-9]+([.][0-9]*)?|[.][0-9]+)):([0-9]*))$ ]]; then 22 | echo -e "${RED}❌ $fw ${NC}" 23 | echo "$url" 24 | 25 | if [ -x "$(command -v w3m)" ]; then 26 | echo "$url_output" | w3m -dump -T text/html 27 | else 28 | echo "$url_output" 29 | fi 30 | 31 | FAIL=1 32 | else 33 | printf "%-34b %4s bytes %s\n" "${GREEN}✔ $fw ${NC}" "${#url_output}" "$url" 34 | fi 35 | else 36 | # if exist in config, but not exist the dir 37 | echo -e "${RED}❌ Dir $fw ${NC} doesn't exist" 38 | FAIL=1 39 | fi 40 | done 41 | 42 | exit $FAIL -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . ./config 4 | . ./base/option_target.sh 5 | 6 | # Colors 7 | GREEN='\033[0;32m' 8 | RED='\033[0;31m' 9 | NC='\033[0m' # No Color 10 | 11 | shopt -s extglob 12 | 13 | for fw in $param_targets 14 | do 15 | echo "> cleaning $fw " 16 | if [ -d "$fw" ]; then 17 | cd "$fw" 18 | . "_benchmark/clean.sh" 19 | cd .. 20 | else 21 | # check for dir 22 | echo -e "${RED}Dir $fw/ doesn't exist!${NC}" 23 | FAIL=1 24 | fi 25 | done -------------------------------------------------------------------------------- /clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! `which composer` ]; then 4 | echo "composer not found." 5 | exit 1; 6 | fi 7 | 8 | 9 | . ./config 10 | . ./base/option_target.sh 11 | 12 | # Colors 13 | GREEN='\033[0;32m' 14 | RED='\033[0;31m' 15 | NC='\033[0m' # No Color 16 | 17 | shopt -s extglob 18 | 19 | for fw in $param_targets 20 | do 21 | echo -n "> clearing cache: $fw " 22 | if [ -d "$fw" ]; then 23 | cd "$fw" 24 | . "_benchmark/clear-cache.sh" 25 | cd .. 26 | else 27 | # check for dir 28 | echo -e "${RED}Dir $fw/ doesn't exist!${NC}" 29 | FAIL=1 30 | fi 31 | done -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf !("_benchmark") 3 | find -path './.*' -delete 4 | rm -rf _benchmark/temp -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # clear cache 3 | rm -rf writable/cache/* 4 | echo -e "done" -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/codeigniter/app/Config/Routes.php: -------------------------------------------------------------------------------- 1 | setDefaultNamespace('App\Controllers'); 20 | $routes->setDefaultController('Home'); 21 | $routes->setDefaultMethod('index'); 22 | $routes->setTranslateURIDashes(false); 23 | $routes->set404Override(); 24 | $routes->setAutoRoute(true); 25 | 26 | /* 27 | * -------------------------------------------------------------------- 28 | * Route Definitions 29 | * -------------------------------------------------------------------- 30 | */ 31 | 32 | // We get a performance increase by specifying the default 33 | // route since we don't have to scan directories. 34 | $routes->get('/', 'Home::index'); 35 | 36 | /* *** PHP-Frameworks-Bench *** */ 37 | $routes->get('/hello/index', 'HelloWorldController::index'); 38 | 39 | /* 40 | * -------------------------------------------------------------------- 41 | * Additional Routing 42 | * -------------------------------------------------------------------- 43 | * 44 | * There will often be times that you need additional routing and you 45 | * need it to be able to override any defaults in this file. Environment 46 | * based routes is one such time. require() additional route files here 47 | * to make that happen. 48 | * 49 | * You will have access to the $routes object within that file without 50 | * needing to reload it. 51 | */ 52 | if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { 53 | require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; 54 | } 55 | -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/codeigniter/app/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | systemDirectory . '/Boot.php'; 55 | 56 | //exit(CodeIgniter\Boot::bootWeb($paths)); 57 | CodeIgniter\Boot::bootWeb($paths); 58 | 59 | /* *** PHP-Frameworks-Bench *** */ 60 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 61 | -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | url="$base/$fw/public/index.php/hello/index" -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # create project 3 | rm -rf _benchmark/temp 4 | composer create-project codeigniter4/appstarter:^4.6 --ansi --no-dev ./_benchmark/temp 5 | mv ./_benchmark/temp/{.,}* ./ 6 | 7 | # have the route & controller 8 | yes|cp -r _benchmark/codeigniter/* ./ 9 | 10 | # some enhancements 11 | composer install --no-dev -o 12 | chmod -R o+w writable 13 | rm ./public/.htaccess -------------------------------------------------------------------------------- /codeigniter-4.6/_benchmark/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer update 3 | 4 | # have the route & controller 5 | yes|cp -r _benchmark/codeigniter/* ./ 6 | 7 | # some enhancements 8 | composer install --no-dev -o 9 | chmod -R o+w writable 10 | rm ./public/.htaccess -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | # base url 2 | base="http://127.0.0.1/PHP-Frameworks-Bench" 3 | 4 | # 30-3000 5 | # a higher duration provides more reliable results 6 | duration=60 7 | 8 | # for a high-end host you may need to put 9 | # a higher number 10 | threads=50 11 | 12 | # consider your webservers configuration 13 | # max live connections 14 | connections=500 15 | 16 | # Frameworks list 17 | # Sorted alphabetically 18 | frameworks_list=" 19 | cakephp-5.1 20 | codeigniter-4.6 21 | fastroute-1.3 22 | fatfree-3.9 23 | kumbia-1.2 24 | laravel-10.3 25 | laravel-11.0 26 | leaf-3.11 27 | lumen-10.0 28 | phroute-2.2 29 | pure-php 30 | silex-2.3 31 | slim-4.14 32 | symfony-5.4 33 | symfony-6.4 34 | symfony-7.0 35 | yii-2.0-basic 36 | " 37 | -------------------------------------------------------------------------------- /docker-apache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! `which docker` ]; then 4 | echo "docker not found." 5 | exit 1; 6 | fi 7 | 8 | PORT=${1:-8080} 9 | 10 | docker build --tag bench/apache -f .docker/apache.dockerfile . 11 | 12 | echo "Runing apache in http://127.0.0.1:$PORT" 13 | echo -e "Press Ctrl+C to stop. \n\n" 14 | 15 | docker run -it --net=host -e PORT="$PORT" -v "$PWD":/var/www/html/PHP-Frameworks-Bench:rw bench/apache:latest 16 | -------------------------------------------------------------------------------- /fastroute-1.3/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | don't be afraid of this code as a basic code, just check the reference 3 | // https://github.com/nikic/FastRoute#usage 4 | // Here's a basic usage example: 5 | 6 | require __DIR__.'/../vendor/autoload.php'; 7 | 8 | 9 | $dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) { 10 | $r->addRoute('GET', '/index.php/hello/index', ['Controllers\HelloWorldController', 'getIndex']); 11 | }); 12 | 13 | // Fetch method and URI from somewhere 14 | $httpMethod = $_SERVER['REQUEST_METHOD']; 15 | $uri = $_SERVER['REQUEST_URI']; 16 | 17 | // Strip query string (?foo=bar) and decode URI 18 | if (false !== $pos = strpos($uri, '?')) { 19 | $uri = substr($uri, 0, $pos); 20 | } 21 | $uri = rawurldecode($uri); 22 | 23 | // https://github.com/nikic/FastRoute/issues/110#issuecomment-273760186 24 | // Strip prefix 25 | $prefix = '/PHP-Frameworks-Bench/fastroute-1.3/public'; 26 | if ($prefix !== '' && strpos($uri, $prefix) === 0) { 27 | $uri = substr($uri, strlen($prefix)); 28 | } 29 | 30 | $routeInfo = $dispatcher->dispatch($httpMethod, $uri); 31 | switch ($routeInfo[0]) { 32 | case FastRoute\Dispatcher::NOT_FOUND: 33 | // ... 404 Not Found 34 | break; 35 | case FastRoute\Dispatcher::METHOD_NOT_ALLOWED: 36 | $allowedMethods = $routeInfo[1]; 37 | // ... 405 Method Not Allowed 38 | break; 39 | case FastRoute\Dispatcher::FOUND: 40 | $handler = $routeInfo[1]; 41 | $vars = $routeInfo[2]; 42 | // ... call $handler with $vars 43 | call_user_func_array([new $handler[0], $handler[1]], $vars); 44 | break; 45 | } 46 | 47 | 48 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 49 | -------------------------------------------------------------------------------- /fatfree-3.9/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | route('GET /index.php/hello/index', 'Controllers\HelloWorldController->index'); 8 | 9 | $f3->run(); 10 | 11 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 12 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PHP Frameworks Bench 7 | 8 | 9 | 10 |

PHP Frameworks Bench

11 | 12 | 83 | 84 | 87 | Results not found! 88 |
    89 |
  • Run bash setup.sh
  • 90 |
  • Run bash check.sh
  • 91 |
  • Run bash benchmark.sh
  • 92 |
93 | " . @$match[1] . ""; 96 | 97 | foreach ($resultsDirs as $res) { 98 | if (preg_match("/output\/(\S+)/", @$res, $match)) { 99 | echo "" . $match[1] . " | "; 100 | } 101 | } 102 | ?> 103 |
104 | 105 |
106 |
107 | 108 |
109 | 110 |
111 | 112 | 115 | 116 | 127 |
128 |
129 | 130 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /kumbia-1.2/_benchmark/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf !("_benchmark") 3 | find -path './.*' -delete 4 | 5 | rm -rf _benchmark/temp 6 | -------------------------------------------------------------------------------- /kumbia-1.2/_benchmark/clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # clear cache 3 | echo -e "!" -------------------------------------------------------------------------------- /kumbia-1.2/_benchmark/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | url="$base/$fw/default/public/index.php/hello/index" 3 | -------------------------------------------------------------------------------- /kumbia-1.2/_benchmark/kumbia/default/app/controllers/hello_controller.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /laravel-10.3/_benchmark/laravel/public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | 57 | 58 | /* *** PHP-Frameworks-Bench *** */ 59 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /laravel-10.3/_benchmark/laravel/routes/web.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /laravel-11.0/_benchmark/laravel/public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 18 | 19 | 20 | /* *** PHP-Frameworks-Bench *** */ 21 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /laravel-11.0/_benchmark/laravel/routes/web.php: -------------------------------------------------------------------------------- 1 | get("/index.php/hello/index", 'Controllers\HelloWorldController@index'); 6 | 7 | app()->run(); 8 | 9 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 10 | -------------------------------------------------------------------------------- /libs/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | PHP-Frameworks-Bench 3 | */ 4 | 5 | const COLORS_ = [ 6 | "#3273a8", 7 | "#3a78ac", 8 | "#437cae", 9 | "#4c80af", 10 | "#5483b0", 11 | "#5d86af", 12 | "#6588ad", 13 | "#6d8aaa", 14 | "#758ba6", 15 | "#7d8ca1", 16 | "#848c9b", 17 | "#8a8c94", 18 | "#908b8b", 19 | "#968a82", 20 | "#9a8878", 21 | "#9f866c", 22 | "#a28360", 23 | "#a57f52", 24 | "#a77b43", 25 | "#a87732", 26 | ]; 27 | 28 | // For more colors 29 | // I'm lazy to regenerate them again 30 | // so lets have a map to make more 31 | let COLORS = dataRPS.map( 32 | (item, index) => 33 | COLORS_[Math.round(index / (dataRPS.length / COLORS_.length))] 34 | ); 35 | 36 | var rpsChart = document.getElementById("rpsChart"); 37 | var memoryChart = document.getElementById("memoryChart"); 38 | var timeChart = document.getElementById("timeChart"); 39 | var fileChart = document.getElementById("fileChart"); 40 | 41 | new Chart(rpsChart, { 42 | type: "bar", 43 | options: { 44 | plugins: { 45 | title: { 46 | display: true, 47 | text: 'Requests Per Second (RPS)' 48 | }, 49 | } 50 | }, 51 | data: { 52 | labels: dataLabels, 53 | datasets: [ 54 | { 55 | label: resultsDatetime, 56 | data: dataRPS, 57 | backgroundColor: COLORS, 58 | }, 59 | ], 60 | }, 61 | }); 62 | 63 | new Chart(memoryChart, { 64 | type: "bar", 65 | options: { 66 | plugins: { 67 | title: { 68 | display: true, 69 | text: 'Memory Peak (MB)' 70 | }, 71 | } 72 | }, 73 | data: { 74 | labels: dataLabels, 75 | datasets: [ 76 | { 77 | label: resultsDatetime, 78 | data: dataMemory, 79 | backgroundColor: COLORS, 80 | }, 81 | ], 82 | }, 83 | }); 84 | 85 | new Chart(timeChart, { 86 | type: "bar", 87 | options: { 88 | plugins: { 89 | title: { 90 | display: true, 91 | text: 'Execution Time (ms)' 92 | }, 93 | } 94 | }, 95 | data: { 96 | labels: dataLabels, 97 | datasets: [ 98 | { 99 | label: resultsDatetime, 100 | data: dataTime, 101 | backgroundColor: COLORS, 102 | }, 103 | ], 104 | }, 105 | }); 106 | 107 | new Chart(fileChart, { 108 | type: "bar", 109 | options: { 110 | plugins: { 111 | title: { 112 | display: true, 113 | text: 'Included Files' 114 | }, 115 | } 116 | }, 117 | data: { 118 | labels: dataLabels, 119 | datasets: [ 120 | { 121 | label: resultsDatetime, 122 | data: dataFile, 123 | backgroundColor: COLORS, 124 | }, 125 | ], 126 | }, 127 | }); 128 | -------------------------------------------------------------------------------- /libs/avg_ms.php: -------------------------------------------------------------------------------- 1 | $result) { 22 | $comp['rps'] = '(-)'; 23 | $comp['memory'] = '(-)'; 24 | if (!empty($res2[$fw])) { 25 | $comp['rps'] = '(' . culc_percentage($result['rps'], $res2[$fw]['rps']) . ')'; 26 | $comp['memory'] = '(' . culc_percentage($result['memory'], $res2[$fw]['memory']) . ')'; 27 | } 28 | 29 | $table .= sprintf( 30 | "|%-19s|%25s|%14s|%11s|%14s|\n", 31 | $fw, 32 | number_format($result['rps'], 2) . ' ' . @$comp['rps'], 33 | is_numeric($result['rps_relative'])?number_format($result['rps_relative'], 1):$result['rps_relative'], 34 | number_format($result['memory'], 2) . ' ' . @$comp['memory'], 35 | is_numeric($result['memory_relative'])?number_format($result['memory_relative'], 1):$result['memory_relative'] 36 | ); 37 | } 38 | 39 | return $table; 40 | } 41 | 42 | function culc_percentage($targetNumber, $baseNumber) 43 | { 44 | if (!is_numeric($targetNumber) || !is_numeric($baseNumber) || $baseNumber<=0) { 45 | return '-'; 46 | } 47 | 48 | $diff = $targetNumber - $baseNumber; 49 | $percentage = ($diff / $baseNumber) * 100; 50 | if ($percentage==0) 51 | return '0%'; 52 | return number_format($percentage, 1).'%'; 53 | } 54 | -------------------------------------------------------------------------------- /libs/output_data.php: -------------------------------------------------------------------------------- 1 | $rps, 30 | 'memory' => round($memory, 2), 31 | 'time' => $time, 32 | 'file' => $file, 33 | ]; 34 | } 35 | 36 | foreach ($results as $fw => $data) { 37 | $results[$fw]['rps_relative'] = $min_rps>0?$data['rps'] / ($min_rps): '-'; 38 | $results[$fw]['memory_relative'] = $min_memory>0?$data['memory'] / ($min_memory): '-'; 39 | $results[$fw]['time_relative'] = $min_time>0?$data['time'] / ($min_time): '-'; 40 | $results[$fw]['file_relative'] = $min_file>0?$data['file'] / ($min_file): '-'; 41 | } 42 | 43 | array_multisort(array_column($results, 'rps'), SORT_DESC, $results); 44 | // var_dump($results); 45 | 46 | return $results; 47 | } 48 | -------------------------------------------------------------------------------- /libs/php_config.php: -------------------------------------------------------------------------------- 1 | $data) { 16 | $results[$fw]['rps_relative'] = $data['rps'] / $min_rps; 17 | $results[$fw]['memory_relative'] = $data['memory'] / $min_memory; 18 | $results[$fw]['time_relative'] = $data['time'] / $min_time; 19 | } 20 | 21 | return $results; 22 | } 23 | -------------------------------------------------------------------------------- /libs/reset_opcache.php: -------------------------------------------------------------------------------- 1 | =0 && preg_match("/output\/(\S+)/", @$results[$compareTo], $match)) { 29 | echo " Compare to:\t\t" . @$match[1] . PHP_EOL; 30 | } 31 | 32 | echo '|-------------------|------------------------:|-------------:|----------:|-------------:|'.PHP_EOL; 33 | 34 | $pr = parse_results(@$results[$index] . '/results.log'); 35 | 36 | if ($compareTo<0) { 37 | echo build_table($pr); 38 | } else { 39 | $prComp = parse_results(@$results[$compareTo] . '/results.log'); 40 | echo build_table($pr, $prComp); 41 | } 42 | -------------------------------------------------------------------------------- /libs/strreplace.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lumen-10.0/_benchmark/lumen/public/index.php: -------------------------------------------------------------------------------- 1 | run(); 29 | 30 | 31 | /* *** PHP-Frameworks-Bench *** */ 32 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /lumen-10.0/_benchmark/lumen/routes/web.php: -------------------------------------------------------------------------------- 1 | get('/', function () use ($router) { 17 | return $router->app->version(); 18 | }); 19 | 20 | $router->get('/hello/index', 'HelloWorldController@index'); 21 | -------------------------------------------------------------------------------- /lumen-10.0/_benchmark/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # create project 3 | rm -rf _benchmark/temp 4 | composer create-project --prefer-dist laravel/lumen:10.0.* ./_benchmark/temp --ansi 5 | mv ./_benchmark/temp/{.,}* ./ 6 | 7 | # have the route & controller 8 | yes|cp -rf _benchmark/lumen/. ./ 9 | 10 | # some enhancements 11 | composer install --no-dev -o --ansi 12 | chmod -R o+w storage 13 | rm ./public/.htaccess -------------------------------------------------------------------------------- /lumen-10.0/_benchmark/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer update 3 | 4 | # have the route & controller 5 | yes|cp -rf _benchmark/lumen/. ./ 6 | 7 | # some enhancements 8 | composer install --no-dev -o 9 | chmod -R o+w storage 10 | rm ./public/.htaccess -------------------------------------------------------------------------------- /phroute-2.2/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | get('/index.php/hello/index', ['Controllers\HelloWorldController', 'getIndex']); 11 | 12 | $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); 13 | 14 | // just same as fastroute: 15 | // https://github.com/nikic/FastRoute/issues/110#issuecomment-273760186 16 | // Strip prefix 17 | $prefix = '/PHP-Frameworks-Bench/phroute-2.2/public'; 18 | if ($prefix !== '' && strpos($uri, $prefix) === 0) { 19 | $uri = substr($uri, strlen($prefix)); 20 | } 21 | 22 | // dont mind the cache, read the readme.md of PHP-Frameworks-Bench 23 | # NB. You can cache the return value from $router->getData() so you don't have to create the routes each request - massive speed gains 24 | $dispatcher = new Phroute\Phroute\Dispatcher($router->getData()); 25 | 26 | $response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], $uri); 27 | 28 | // Print out the value returned from the dispatched function 29 | echo $response; 30 | 31 | 32 | /* *** PHP-Frameworks-Bench *** */ 33 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 34 | -------------------------------------------------------------------------------- /pure-php/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | get('/hello/index', 'Controllers\HelloWorldController::getIndex'); 10 | 11 | $app->run(); 12 | 13 | /* *** PHP-Frameworks-Bench *** */ 14 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 15 | -------------------------------------------------------------------------------- /slim-4.13/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | getBody()->write("Hello World!"); 17 | return $response; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /slim-4.13/_benchmark/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf !("_benchmark"|"Controllers"|"composer.json"|"public") 3 | find -path './.*' -delete -------------------------------------------------------------------------------- /slim-4.13/_benchmark/clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # clear cache 3 | echo -e "!" -------------------------------------------------------------------------------- /slim-4.13/_benchmark/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | url="$base/$fw/public/index.php/hello/index" -------------------------------------------------------------------------------- /slim-4.13/_benchmark/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer install --no-dev -o --ansi -------------------------------------------------------------------------------- /slim-4.13/_benchmark/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer update -------------------------------------------------------------------------------- /slim-4.13/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "slim/slim": "4.13.*", 4 | "slim/psr7": "1.6.*", 5 | "slim/http": "1.3.*" 6 | }, 7 | "autoload": { 8 | "psr-4": { 9 | "Controllers\\": "Controllers/" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /slim-4.13/public/index.php: -------------------------------------------------------------------------------- 1 | setBasePath("/PHP-Frameworks-Bench/slim-4.13/public/index.php"); 11 | 12 | // Add error middleware 13 | $app->addErrorMiddleware(false, true, true); 14 | 15 | /* *** PHP-Frameworks-Bench *** */ 16 | $app->get('/hello/index', Controllers\HelloWorldController::class . ':index'); 17 | 18 | $app->run(); 19 | 20 | 21 | /* *** PHP-Frameworks-Bench *** */ 22 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 23 | -------------------------------------------------------------------------------- /slim-4.14/Controllers/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | getBody()->write("Hello World!"); 17 | return $response; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /slim-4.14/_benchmark/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf !("_benchmark"|"Controllers"|"composer.json"|"public") 3 | find -path './.*' -delete -------------------------------------------------------------------------------- /slim-4.14/_benchmark/clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # clear cache 3 | echo -e "!" -------------------------------------------------------------------------------- /slim-4.14/_benchmark/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | url="$base/$fw/public/index.php/hello/index" -------------------------------------------------------------------------------- /slim-4.14/_benchmark/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer install --no-dev -o --ansi -------------------------------------------------------------------------------- /slim-4.14/_benchmark/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | composer update -------------------------------------------------------------------------------- /slim-4.14/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "slim/slim": "4.14.*", 4 | "slim/psr7": "1.7.*", 5 | "slim/http": "1.4.*" 6 | }, 7 | "autoload": { 8 | "psr-4": { 9 | "Controllers\\": "Controllers/" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /slim-4.14/public/index.php: -------------------------------------------------------------------------------- 1 | setBasePath("/PHP-Frameworks-Bench/slim-4.14/public/index.php"); 11 | 12 | // Add error middleware 13 | $app->addErrorMiddleware(false, true, true); 14 | 15 | /* *** PHP-Frameworks-Bench *** */ 16 | $app->get('/hello/index', Controllers\HelloWorldController::class . ':index'); 17 | 18 | $app->run(); 19 | 20 | 21 | /* *** PHP-Frameworks-Bench *** */ 22 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; 23 | -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf !("_benchmark") 3 | find -path './.*' -delete 4 | rm -rf _benchmark/temp -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/clear-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # clear cache 3 | bin/console cache:clear -q 4 | echo -e "done" -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/hello_world.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | url="$base/$fw/public/index.php/hello/index" -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # create project 3 | rm -rf _benchmark/temp 4 | composer create-project symfony/skeleton:5.4.* ./_benchmark/temp --ansi 5 | mv ./_benchmark/temp/{.,}* ./ 6 | 7 | # have the route & controller 8 | yes|cp -r _benchmark/symfony/* ./ 9 | 10 | # some enhancements 11 | composer dump-env prod --ansi 12 | APP_ENV=prod APP_DEBUG=0 bin/console cache:clear 13 | composer install --no-dev --optimize-autoloader --ansi 14 | chmod -R o+w var -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/symfony/config/routes.yaml: -------------------------------------------------------------------------------- 1 | #index: 2 | # path: / 3 | # controller: App\Controller\DefaultController::index 4 | hello_world: 5 | path: /hello/index 6 | controller: App\Controller\HelloWorldController::index -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/symfony/public/index.php: -------------------------------------------------------------------------------- 1 | handle($request); 16 | $response->send(); 17 | $kernel->terminate($request, $response); 18 | 19 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /symfony-5.4/_benchmark/symfony/src/Controller/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | handle($request); 16 | $response->send(); 17 | $kernel->terminate($request, $response); 18 | 19 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /symfony-6.4/_benchmark/symfony/src/Controller/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | handle($request); 16 | $response->send(); 17 | $kernel->terminate($request, $response); 18 | 19 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; -------------------------------------------------------------------------------- /symfony-7.0/_benchmark/symfony/src/Controller/HelloWorldController.php: -------------------------------------------------------------------------------- 1 | run(); 13 | 14 | /* *** PHP-Frameworks-Bench *** */ 15 | require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php'; --------------------------------------------------------------------------------