Hulotte Middleware Dispatcher is a package that allows you to manage the launch of middlewares with a queue system. This package respects PSR15 standards.
The easiest way to install Hulotte Middleware Dispatcher is to use Composer with this command :
$ composer require hulotte/middleware-dispatcher
First, instanciate the MiddlewareDispatcher class with an array of middlewares.
$dispatcher = new \Hulotte\Middlewares\MiddlewareDispatcher([
new Middleware1(),
new Middleware2(),
]);
the order of the middlewares in the array is important: it represents the order in which the middlewares will be played.
Now you can call the handle method. The request must implement the ServerRequestInterface (PSR7 standards).
$dispatcher->handle($request);