A simple PSR-15 compatible middleware dispatcher.
v3 breaking changes: updated to use "http-interop/http-middleware" v0.5 where Delegate has been replaced with ResponseHandler.
- PHP7+
- A stack of PSR-15 middleware, such as Router or Middlewares
- A PSR-17 HTTP factory
- An invoker compatible with InvokerInterface
Via Composer
$ composer require ideationnet/stack-runner
To instantiate directly, provide the stack of middleware, the invoker to use, and the response factory:
$runner = new IdNet\StackRunner($middleware, $invoker, $factory);
$response = $runner->dispatch($request);
Although you will probably use with your preferred DI Container rather than instantiating directly:
$runner = $container->get(StackRunner::class);
Here's configuration for PHP-DI, which is
preferred, as the container also doubles as a compatible Invoker
:
return [
StackRunner::class => object()
->constructorParameter('stack', get('middleware')),
];
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License. Please see License File for more information.