techworker / middleware
PSR-7 middleware function for building and dispatching middlewares.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:HTML
Requires
- psr/http-message: ^1.0
Requires (Dev)
- oscarotero/psr7-middlewares: ^3.0
- phpunit/phpunit: ^6.1
- ramsey/uuid: ^3.6
- zendframework/zend-diactoros: ^1.4
README
This library provides a single function to implement a PHP 7 middleware workflow for your PHP applications.
It is heavily inspired from the relay php implementation by Paul M. Jones
Usage
Import the function and define a list of middlewares.
<?php use Psr7Middlewares\Middleware; use Psr7Middlewares\Middleware\ErrorHandler; use function Techworker\Functional\middleware; /** * This function checks whether the 'Authorization' is given. */ $middleware1 = function( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, callable $next ) { return $next($request, $response); }; $middlewares = [$middleware1, \Psr7Middlewares\Middleware::uuid()]; middleware($request, $response, $middlewares);
Installation
Add this to your composer.json
"require": { "techworker/middleware": "^1.0" }
.. or use the following command on your command line:
composer require techworker/middleware