2017 © Pedro Peláez
 

library http

HTTP middlewares for PSR-7 and PSR-15

image

stratify/http

HTTP middlewares for PSR-7 and PSR-15

  • Sunday, July 23, 2017
  • by mnapoli
  • Repository
  • 2 Watchers
  • 2 Stars
  • 424 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 2 % Grown

The README.md

Stratify HTTP stack

HTTP middleware utilities built upon:, (*1)

composer require stratify/http

Middlewares

A middleware can be either an instance of Psr\Http\Server\MiddlewareInterface:, (*2)

class MyMiddleware implements \Psr\Http\Server\MiddlewareInterface
{
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
    {
        return new Response(...);
    }
}

$middleware = new MyMiddleware;

or a simple callable, which allows to use closures for quickly writing middlewares:, (*3)

$middleware = function(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface {
    return new Response(...);
}

Middleware pipe

The middleware pipe let us pipe middlewares to execute one after the other. It is similar to using the pipe (|) operator on the command line., (*4)

It's interesting to note that the pipe is also a middleware, which means it can be nested or combined with any other middleware., (*5)

Usage:, (*6)

$middleware = new Pipe([
    new Middleware1,
    new Middleware2,
    // ...
]);

// Run
$response = $middleware->process($request, $handler);

The pipe will first execute Middleware1. If that middleware calls $next then Middleware2 will be executed. An infinite number of middlewares can be piped together., (*7)

If you don't need to use the $handler argument for the pipe, you can use the LastHandler class:, (*8)

$response = $middleware->process($request, new \Stratify\Http\Middleware\LastHandler);

The Versions

23/07 2017

dev-master

9999999-dev

HTTP middlewares for PSR-7 and PSR-15

  Sources   Download

MIT

The Requires

 

The Development Requires

23/07 2017

0.5.0

0.5.0.0

HTTP middlewares for PSR-7 and PSR-15

  Sources   Download

MIT

The Requires

 

The Development Requires

18/10 2016
20/08 2016

0.4.0

0.4.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

15/08 2016

0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

07/08 2016

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

07/08 2016

0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

01/09 2015

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires