noa / middleware-handler
A simple PSR-7 / PSR-15 middleware handler
1.0.0
2017-09-20 16:30 UTC
Requires
- guzzlehttp/psr7: ^1.4
- http-interop/http-middleware: ^0.4.1
- http-interop/response-sender: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: 6.3
This package is not auto-updated.
Last update: 2025-03-02 05:03:22 UTC
README
Yet another middlewares dispatcher
Description
Just a simple PSR-15 middleware dispatcher
Installation
composer require noa/middleware-handle
Usage
$request = ServerRequest::fromGlobals();
$stack = new MiddlewaresHandler();
$response = $stack->create()
->pipe(new App())
->pipe(new Middleware1())
->pipe(new Middleware2())
->pipe(new Middleware3())
->process($request);
The request will pass throught Middleware3, then Middleware2, then Middleware1, then App.
When App return its response, Middleware1 will do something or not like Middleware 2 and 3.
Finally Middleware3 give its response to MiddlewareHandler::process method which return this $response