borsch/middlewares

A collection of common PSR-15 Middleware.

1.2 2020-05-01 12:57 UTC

This package is auto-updated.

Last update: 2022-04-29 01:34:44 UTC


README

A collection of common PSR-15 Middleware for Borsch applications.

This package is part of the Borsch Framework.

Installation

Via composer :

composer require borsch/middlewares

Usage

require_once __DIR__.'/vendor/autoload.php';

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());

License

The package is licensed under the MIT license. See License File for more information.