Download the PHP package mehr-it/eli-middleware-chain without Composer
On this page you can find all versions of the php package mehr-it/eli-middleware-chain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mehr-it/eli-middleware-chain
More information about mehr-it/eli-middleware-chain
Files in mehr-it/eli-middleware-chain
Package eli-middleware-chain
Short Description Chaining for PSR-15 middleware
License MIT
Informations about the package eli-middleware-chain
PSR middleware chain
When defining a request processing chain, usually more than one middleware is involved into the
processing chain. The ChainHandler allows to define the PSR-15 middleware processing stack as
array or iterator:
$chain = new ChainHandler([
new MiddlewareA(),
new MiddlewareB(),
], $next);
This makes code much more readable and allows easy dynamic configuration of the middleware chain.
To create middleware instances on the fly - only when needed - resolver functions may be used:
$chain = new ChainHandler([
function() { return new MiddlewareA(); },
function() { return new MiddlewareB(); },
], $next);
Middleware instead of handler
Sometimes a middleware chain is required as middleware itself. The ChainMiddleware can be used
for such purposes. It's usage is straightforward as the ChainHandler:
$chain = new ChainMiddleware([
new MiddlewareA(),
new MiddlewareB(),
]); All versions of eli-middleware-chain with dependencies
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0