hulotte/middleware-dispatcher

A PSR-15 middleware dispatcher

1.0.0 2020-12-24 17:06 UTC

This package is auto-updated.

Last update: 2024-04-25 00:53:35 UTC


README

Description

Hulotte Middleware Dispatcher is a package that allows you to manage the launch of middlewares with a queue system. This package respects PSR15 standards.

Installation

The easiest way to install Hulotte Middleware Dispatcher is to use Composer with this command :

$ composer require hulotte/middleware-dispatcher

How to use 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);