2017 © Pedro Peláez
 

library middleware

Lightweight middleware implementation. 1 class,

image

siriusphp/middleware

Lightweight middleware implementation. 1 class,

  • Tuesday, June 21, 2016
  • by adrianmiu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 35 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Sirius Middleware

Source Code Latest Version Software License Build Status Coverage Status Quality Score, (*1)

Regular middleware


$middlewares = array(); $middlewares[] = function(RequestInterface $request, ResponseInterface $response, callable $next = null) { // do your thing return $response; }; $middlewares[] = function(RequestInterface $request, ResponseInterface $response, callable $next = null) { // do your thing return $response; }; $runner = Sirius\Middleware\Runner::factory($middlewares); $response = $runner(Zend\Diactoros\ServerRequestFactory::fromGlobals(), new Zend\Diactoros\Response);

The middleware runners are immutable so adding a new middleware returns a new runner. If you want to create the runner by hand, (*2)


// this is WRONG!!!!!!!!! $runner = new Sirius\Middleware\Runner; $runner->add(function(RequestInterface $request, ResponseInterface $response, callable $next = null) { // do your thing return $response; }); $runner->add(function(RequestInterface $request, ResponseInterface $response, callable $next = null) { // do your thing return $response; }); // this is CORRECT $runner = (new Sirius\Middleware\Runner) ->add(function(RequestInterface $request, ResponseInterface $response, callable $next = null) { // do your thing return $response; }) ->add(function(RequestInterface $request, ResponseInterface $response, callable $next = null) { // do your thing return $response; });

Frame middleware

Inspired by this article http://blog.ircmaxell.com/2016/05/all-about-middleware.html, (*3)


$middlewares = array(); // first middleware in the stack must return an response $middlewares[] = function(RequestInterface $request, callable $next = null) { return new Zend\Diactoros\Response; }; $middlewares[] = function(RequestInterface $request, callable $next = null) { // do your thing return $response; }; $middlewares[] = function(RequestInterface $request, callable $next = null) { // do your thing return $response; }; $runner = Sirius\Middleware\FrameRunner::factory($middlewares); $response = $runner(Zend\Diactoros\ServerRequestFactory::fromGlobals());

The Versions

21/06 2016

dev-master

9999999-dev https://github.com/sirius/middleware

Lightweight middleware implementation. 1 class,

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

middleware psr psr-7 http request response zend-diactoros

21/06 2016

1.1.0

1.1.0.0 https://github.com/sirius/middleware

Lightweight middleware implementation. 1 class,

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

middleware psr psr-7 http request response zend-diactoros

11/06 2016

1.0.0

1.0.0.0 https://github.com/sirius/middleware

Lightweight middleware implementation. 1 class,

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

middleware psr psr-7 http request response zend-diactoros