PHP code example of gabbro-php / middleware

1. Go to this page and download the library: Download gabbro-php/middleware library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gabbro-php / middleware example snippets


  $engine = new OrderedStackEngine();
  $engine->addMiddleware(10, Verb::ANY, SomeAuthMiddleware::class);
  $engine->addMiddleware(50, Verb::GET|Verb::POST, new MiddlewareRouter());
  $response = $engine->process($request);
  

  $router = new MiddlewareRouter();
  $router->addRoute("/hello", Verb::GET, fn($req) => new Response("Hello World"));
  $response = $router->process($request);