Skip to content

Commit

Permalink
Merge pull request #53 from myaaghubi/v2.4.1
Browse files Browse the repository at this point in the history
V2.4.1
  • Loading branch information
myaaghubi authored Dec 7, 2023
2 parents 09852e7 + be5f66c commit 3358a16
Show file tree
Hide file tree
Showing 42 changed files with 395 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .docker/apache.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2-apache
FROM php:8.3-apache

RUN apt-get update \
&& apt-get install -y libicu-dev
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
setup:
name: Check PHP frameworks
runs-on: ubuntu-22.04

steps:

- uses: actions/checkout@v3
Expand All @@ -16,15 +16,15 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, ctype, iconv, intl
coverage: none

- name: Install Apache mod_php
run: |
LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu
sudo apt install libapache2-mod-php8.2
sudo a2enmod php8.2 rewrite
sudo apt install libapache2-mod-php8.3
sudo a2enmod php8.3 rewrite
shell: bash

- name: Setup frameworks
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ These are my benchmarks, not yours. **I encourage you to run on your -production
|lumen-10.0 | 325.27| 3.9| 3.61| 8.6|
|symfony-5.4 | 309.74| 3.7| 3.77| 9.0|
|codeigniter-4.4 | 302.21| 3.6| 3.62| 8.6|
|symfony-6.4 | 278.58| 3.3| 4.11| 9.8|
|symfony-7.0 | 286.46| 3.4| 4.07| 9.7|
|symfony-6.4 | 280.83| 3.3| 4.11| 9.8|
|cakephp-4.5 | 246.72| 2.9| 4.63| 11.0|
|cakephp-5.0 | 243.96| 2.9| 4.74| 11.3|
|laravel-10.2 | 84.19| 1.0| 13.06| 31.0|


#### OPCache On
Check out the video for more information.

[![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)


Expand Down Expand Up @@ -182,9 +185,7 @@ $ bash benchmark.sh -t laravel-10.2/ slim-4.12/ ...


## Add Your Framework
Check out the [Benchmarking Policy](#benchmarking-policy), to get more information watch the video

[OPCache On/Off](#opcache-on).
Check out the [Benchmarking Policy](#benchmarking-policy), to get more information watch the video [OPCache On/Off](#opcache-on).


## Benchmarking Policy
Expand Down
4 changes: 2 additions & 2 deletions cakephp-4.5/_benchmark/setup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh
# create project
rm -rf _benchmark/temp
composer create-project --prefer-dist cakephp/app:4.5.* ./_benchmark/temp
composer create-project --prefer-dist cakephp/app:4.5.* ./_benchmark/temp --ansi
yes|mv ./_benchmark/temp/{.,}* ./

# have the route & controller
yes|cp -r _benchmark/cakephp/* ./

# some enhancements
composer dump-autoload -o
composer install --no-interaction --no-dev -o
composer install --no-interaction --no-dev -o --ansi
rm ./webroot/.htaccess
95 changes: 95 additions & 0 deletions cakephp-5.0/_benchmark/cakephp/config/app_local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/*
* Local configuration file to provide any overrides to your app.php configuration.
* Copy and save this file as app_local.php and make changes as required.
* Note: It is not recommended to commit files with credentials such as app_local.php
* into source code version control.
*/
return [
/*
* Debug Level:
*
* Production Mode:
* false: No error messages, errors, or warnings shown.
*
* Development Mode:
* true: Errors and warnings shown.
*/
/* *** PHP-Frameworks-Bench *** */
'debug' => false,

/*
* Security and encryption configuration
*
* - salt - A random string used in security hashing methods.
* The salt value is also used as the encryption key.
* You should treat it as extremely sensitive data.
*/
'Security' => [
'salt' => env('SECURITY_SALT', '__SALT__'),
],

/*
* Connection information used by the ORM to connect
* to your application's datastores.
*
* See app.php for more configuration options.
*/
'Datasources' => [
'default' => [
'host' => 'localhost',
/*
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',

'username' => 'my_app',
'password' => 'secret',

'database' => 'my_app',
/*
* If not using the default 'public' schema with the PostgreSQL driver
* set it here.
*/
//'schema' => 'myapp',

/*
* You can use a DSN string to set the entire configuration
*/
'url' => env('DATABASE_URL', null),
],

/*
* The test connection is used during the test suite.
*/
'test' => [
'host' => 'localhost',
//'port' => 'non_standard_port_number',
'username' => 'my_app',
'password' => 'secret',
'database' => 'test_myapp',
//'schema' => 'myapp',
'url' => env('DATABASE_TEST_URL', 'sqlite://127.0.0.1/tests.sqlite'),
],
],

/*
* Email configuration.
*
* Host and credential configuration in case you are using SmtpTransport
*
* See app.php for more configuration options.
*/
'EmailTransport' => [
'default' => [
'host' => 'localhost',
'port' => 25,
'username' => null,
'password' => null,
'client' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
];
94 changes: 94 additions & 0 deletions cakephp-5.0/_benchmark/cakephp/config/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Routes configuration.
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different URLs to chosen controllers and their actions (functions).
*
* It's loaded within the context of `Application::routes()` method which
* receives a `RouteBuilder` instance `$routes` as method argument.
*
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://opensource.org/licenses/mit-license.php MIT License
*/

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;

return function (RouteBuilder $routes): void {
/*
* The default class to use for all routes
*
* The following route classes are supplied with CakePHP and are appropriate
* to set as the default:
*
* - Route
* - InflectedRoute
* - DashedRoute
*
* If no call is made to `Router::defaultRouteClass()`, the class used is
* `Route` (`Cake\Routing\Route\Route`)
*
* Note that `Route` does not do any inflections on URLs which will result in
* inconsistently cased URLs when used with `:plugin`, `:controller` and
* `:action` markers.
*/
$routes->setRouteClass(DashedRoute::class);

/* *** PHP-Frameworks-Bench *** */
$routes->connect('/hello/index', ['controller' => 'HelloWorld', 'action' => 'display', 'home']);

$routes->scope('/', function (RouteBuilder $builder) {
/*
* Here, we are connecting '/' (base path) to a controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, templates/Pages/home.php)...
*/
$builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);

/*
* ...and connect the rest of 'Pages' controller's URLs.
*/
$builder->connect('/pages/*', 'Pages::display');

/*
* Connect catchall routes for all controllers.
*
* The `fallbacks` method is a shortcut for
*
* ```
* $builder->connect('/:controller', ['action' => 'index']);
* $builder->connect('/:controller/:action/*', []);
* ```
*
* You can remove these routes once you've connected the
* routes you want in your application.
*/
$builder->fallbacks();
});

/*
* If you need a different set of middleware or none at all,
* open new scope and define routes there.
*
* ```
* $routes->scope('/api', function (RouteBuilder $builder) {
* // No $builder->applyMiddleware() here.
*
* // Parse specified extensions from URLs
* // $builder->setExtensions(['json', 'xml']);
*
* // Connect API actions here.
* });
* ```
*/
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types=1);

/*
PHP-Frameworks-Bench
this is a simple hello world controller to make benchmark
*/

namespace App\Controller;

// such simple controller
class HelloWorldController extends AppController {

public function display()
{
return $this->response->withStringBody('Hello World!');
}
}
40 changes: 40 additions & 0 deletions cakephp-5.0/_benchmark/cakephp/webroot/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* The Front Controller for handling every request
*
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.2.9
* @license MIT License (https://opensource.org/licenses/mit-license.php)
*/

// For built-in server
if (PHP_SAPI === 'cli-server') {
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);

$url = parse_url(urldecode($_SERVER['REQUEST_URI']));
$file = __DIR__ . $url['path'];
if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
return false;
}
}
require dirname(__DIR__) . '/vendor/autoload.php';

use App\Application;
use Cake\Http\Server;

// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));

// Run the request/response through the application and emit the response.
$server->emit($server->run());

/* *** PHP-Frameworks-Bench *** */
require $_SERVER['DOCUMENT_ROOT'].'/PHP-Frameworks-Bench/libs/output_data.php';
4 changes: 4 additions & 0 deletions cakephp-5.0/_benchmark/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
rm -rf !("_benchmark")
find -path './.*' -delete
rm -rf _benchmark/temp
4 changes: 4 additions & 0 deletions cakephp-5.0/_benchmark/clear-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# clear cache
bin/cake cache clear_all
echo -e "done"
2 changes: 2 additions & 0 deletions cakephp-5.0/_benchmark/hello_world.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
url="$base/$fw/webroot/index.php/hello/index"
13 changes: 13 additions & 0 deletions cakephp-5.0/_benchmark/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# create project
rm -rf _benchmark/temp
composer create-project --prefer-dist cakephp/app:5.0.* ./_benchmark/temp --ansi
yes|mv ./_benchmark/temp/{.,}* ./

# have the route & controller
yes|cp -r _benchmark/cakephp/* ./

# some enhancements
composer dump-autoload -o
composer install --no-interaction --no-dev -o --ansi
rm ./webroot/.htaccess
10 changes: 10 additions & 0 deletions cakephp-5.0/_benchmark/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
composer update

# have the route & controller
yes|cp -r _benchmark/cakephp/* ./

# some enhancements
composer dump-autoload -o
composer install --no-interaction --no-dev -o
rm ./webroot/.htaccess
2 changes: 1 addition & 1 deletion codeigniter-4.4/_benchmark/setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# create project
rm -rf _benchmark/temp
composer create-project codeigniter4/appstarter:^4.4 --no-dev ./_benchmark/temp
composer create-project codeigniter4/appstarter:^4.4 --ansi --no-dev ./_benchmark/temp
mv ./_benchmark/temp/{.,}* ./

# have the route & controller
Expand Down
2 changes: 2 additions & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ connections=500
# Sorted alphabetically
frameworks_list="
cakephp-4.5
cakephp-5.0
codeigniter-4.4
fastroute-1.3
fatfree-3.8
Expand All @@ -31,6 +32,7 @@ silex-2.3
slim-4.12
symfony-5.4
symfony-6.4
symfony-7.0
ubiquity-2.4.x.dev
yii-2.0-basic
"
Loading

0 comments on commit 3358a16

Please sign in to comment.