Download the PHP package ellipse/dispatcher-composable without Composer
On this page you can find all versions of the php package ellipse/dispatcher-composable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ellipse/dispatcher-composable
More information about ellipse/dispatcher-composable
Files in ellipse/dispatcher-composable
Package dispatcher-composable
Short Description Composable dispatcher factory
License MIT
Homepage https://github.com/ellipsephp/dispatcher-composable
Informations about the package dispatcher-composable
Composable resolver
This package provides a composable factory decorator for objects implementing Ellipse\DispatcherFactoryInterface
from ellipse/dispatcher package.
Require php >= 7.0
Installation composer require ellipse/dispatcher-composable
Run tests ./vendor/bin/kahlan
- Composing a dispatcher
Composing a dispatcher
Sometimes a dispatcher needs to be composed at runtime according to certain conditions. When routing for example: a solution is needed to build a dispatcher using different middleware queues and request handlers according to the matched route.
For this purpose this package provides an Ellipse\Dispatcher\ComposableResolver
class which takes an implementation of DispatcherFactoryInterface
and a middleware queue as constructor parameters. Dispatchers produced by this resolver are wrapped inside this middleware queue. It also have a ->with()
method taking a middleware queue as parameter and returning a new ComposableResolver
with those middleware added to the queue.
Let's have an example using FastRoute:
Of course, ComposableResolver
can decorate any implementation of DispatcherFactoryInterface
. For example the CallableResolver
class from the ellipse/dispatcher-callable package: