krak / mw
Middleware Framework
Installs: 1 041
Dependents: 7
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 3
Requires
- php: >=5.6
- krak/invoke: ^0.1.0
Requires (Dev)
- krak/cargo: ^0.2.0
- nikic/iter: ^1.4
- peridot-php/peridot: ^1.18
- psr/container: ^1.0
README
The Mw library is a very flexible framework for converting middleware into handlers. Middleware offer a clean syntax for implementing the Decorator Pattern
<?php use Krak\Mw; $handler = mw\compose([ function($s, $next) { return strtoupper($s); }, function($s, $next) { return 'x' . $next($s . 'x'); } ]); $res = $handler('abc'); assert($res == 'xABCX');
Installation
You can install this as a composer package at krak/mw
Documentation
View them at http://mw.readthedocs.io/en/latest/
Or build them:
make doc
Tests and Examples
Run tests via:
make test
The Mw library uses Peridot. These tests also provide good examples of how to use the library.