This repository was archived by the owner on Mar 24, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ http://localhost:8080/db
1515
1616### QUERY
1717
18- http://localhost:8080/query /[count ]
18+ http://localhost:8080/queries /[count ]
1919
2020### UPDATE
2121
22- http://localhost:8080/update /[count ]
22+ http://localhost:8080/updates /[count ]
2323
2424### FORTUNES
2525
Original file line number Diff line number Diff line change 1616 ],
1717 'orm ' => 'pdo ' ,
1818 'pdo ' => [
19- 'dsn ' => 'pgsql :host=tfb-database ;dbname=hello_world ' ,
20- 'username ' => 'benchmarkdbuser ' ,
21- 'password ' => 'benchmarkdbpass ' ,
19+ 'dsn ' => 'mysql :host=127.0.0.1 ;dbname=hello_world ' ,
20+ 'username ' => 'root ' ,
21+ 'password ' => 'root ' ,
2222 'options ' => [
2323 PDO ::ATTR_ERRMODE => PDO ::ERRMODE_EXCEPTION ,
2424 PDO ::ATTR_DEFAULT_FETCH_MODE => PDO ::FETCH_ASSOC ,
Original file line number Diff line number Diff line change @@ -38,10 +38,10 @@ public function fortunes()
3838 return Response::html ("<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr> $ html</table></body></html> " );
3939 }
4040
41- public function queries ($ q = 1 )
41+ public function queries ($ q= 1 )
4242 {
4343 $ statement = app ()->db ->prepare ('SELECT id,randomNumber FROM World WHERE id=? ' );
44- $ query_count = min ( max (( int ) $ q , 1 ), 500 );
44+ $ query_count = max (min ( intval ( $ q ), 500 ), 1 );
4545 $ arr = [];
4646 while ($ query_count --) {
4747 $ statement ->execute ([mt_rand (1 , 10000 )]);
@@ -50,12 +50,12 @@ public function queries($q = 1)
5050 return Response::json ($ arr );
5151 }
5252
53- public function updates ($ q = 1 )
53+ public function updates ($ q= 1 )
5454 {
5555 static $ updates = [];
5656
5757 $ random = app ()->db ->prepare ('SELECT id,randomNumber FROM World WHERE id=? ' );
58- $ count = min ( max (( int ) $ q , 1 ), 500 );
58+ $ count = max (min ( intval ( $ q ), 500 ), 1 );
5959
6060 $ worlds = $ keys = $ values = [];
6161 for ($ i = 0 ; $ i < $ count ; ++ $ i ) {
Original file line number Diff line number Diff line change @@ -91,16 +91,22 @@ public function run()
9191 $ requestMiddlewares = $ this ->getConfig ('request_middleware ' );
9292
9393 /* Execute request object middleware */
94- $ this ->request = $ this ->middleware ->handleRequest ($ requestMiddlewares );
94+ if (!empty ($ requestMiddlewares )){
95+ $ this ->request = $ this ->middleware ->handleRequest ($ requestMiddlewares );
96+ }
9597
9698 /* Parse route and return the closure to be executed */
9799 $ handleRoute = $ this ->route ->handleRoute ();
98100 /* Middleware list */
99101 $ Middlewares = $ this ->getConfig ('middleware ' );
100102 /* Execute middleware */
101- $ response = $ this ->middleware ->handle ($ Middlewares ,function () use ($ handleRoute ) {
102- return $ handleRoute ;
103- });
103+ if (!empty ($ Middlewares )){
104+ $ response = $ this ->middleware ->handle ($ Middlewares ,function () use ($ handleRoute ) {
105+ return $ handleRoute ;
106+ });
107+ }else {
108+ $ response = $ handleRoute ;
109+ }
104110 /* Return response */
105111 return $ response ;
106112 }
Original file line number Diff line number Diff line change @@ -40,14 +40,14 @@ public function handleRoute()
4040 } elseif ($ routeInfo [0 ] == 1 ) {
4141 $ handler = $ routeInfo [1 ];
4242 $ vars = $ routeInfo [2 ];
43- $ parameters = [$ request , ...array_values ($ vars )];
43+ $ parameters = [...array_values ($ vars )];
4444
4545 // Create a closure to pass to your middleware to execute the final handler
4646 $ finalHandler = function () use ($ handler , $ parameters , $ container ) {
4747 // If handler is a string (controller@method)
4848 if (is_string ($ handler )) {
4949 list ($ controller , $ method ) = explode ('@ ' , $ handler );
50- $ class = $ container -> get ( $ controller );
50+ $ class = new $ controller( );
5151 return $ class ->$ method (...$ parameters );
5252 } elseif (is_callable ($ handler )) {
5353 return $ handler (...$ parameters );
You can’t perform that action at this time.
0 commit comments