noa/middleware-handler

A simple PSR-7 / PSR-15 middleware handler

1.0.0 2017-09-20 16:30 UTC

This package is not auto-updated.

Last update: 2024-04-14 00:54:33 UTC


README

Build Status codecov

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

Development