PHP code example of borsch / middlewares

1. Go to this page and download the library: Download borsch/middlewares 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/ */

    

borsch / middlewares example snippets




use Borsch\RequestHandler\RequestHandler;
use Borsch\Middleware\ErrorHandlerMiddleware;
use Borsch\Middleware\RouteMiddleware;
use Borsch\Middleware\ImplicitHeadMiddleware;
use Borsch\Middleware\ImplicitOptionsMiddleware;
use Borsch\Middleware\MethodNotAllowedMiddleware;
use \Borsch\Middleware\DispatchMiddleware;
use \Borsch\Middleware\NotFoundHandlerMiddleware;

$request_handler = new RequestHandler();

$request_handler->middlewares([
    ErrorHandlerMiddleware::class,
    RouteMiddleware::class,
    ImplicitHeadMiddleware::class,
    ImplicitOptionsMiddleware::class,
    MethodNotAllowedMiddleware::class,
    DispatchMiddleware::class,
    NotFoundHandlerMiddleware::class
]);

$response = $request_handler->handle(ServerRequestFactory::fromGlobals());