Skip to content

Commit

Permalink
Merge pull request #48 from joanhey/cakephp-5
Browse files Browse the repository at this point in the history
Cakephp 5
  • Loading branch information
myaaghubi committed Dec 5, 2023
2 parents 09852e7 + 04523c0 commit c119a27
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 0 deletions.
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
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
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
1 change: 1 addition & 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 Down

0 comments on commit c119a27

Please sign in to comment.