PHPackages                             ellipse/dispatcher-composable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ellipse/dispatcher-composable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ellipse/dispatcher-composable
=============================

Composable dispatcher factory

1.0.0(8y ago)127MITPHPPHP &gt;=7.0

Since Mar 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ellipsephp/dispatcher-composable)[ Packagist](https://packagist.org/packages/ellipse/dispatcher-composable)[ Docs](https://github.com/ellipsephp/dispatcher-composable)[ RSS](/packages/ellipse-dispatcher-composable/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Composable resolver
===================

[](#composable-resolver)

This package provides a composable factory decorator for objects implementing `Ellipse\DispatcherFactoryInterface` from [ellipse/dispatcher](https://github.com/ellipsephp/dispatcher) package.

**Require** php &gt;= 7.0

**Installation** `composer require ellipse/dispatcher-composable`

**Run tests** `./vendor/bin/kahlan`

- [Composing a dispatcher](#composing-a-dispatcher)

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](https://github.com/nikic/FastRoute):

```
