PHPackages                             caridea/dispatch - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. caridea/dispatch

ActiveLibrary[HTTP &amp; Networking](/categories/http)

caridea/dispatch
================

A shrimp of a PSR-15 compliant middleware dispatcher

3.0.0(8y ago)218Apache-2.0PHPPHP &gt;=7.1.0

Since Feb 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/libreworks/caridea-dispatch)[ Packagist](https://packagist.org/packages/caridea/dispatch)[ Docs](http://github.com/libreworks/caridea-dispatch)[ RSS](/packages/caridea-dispatch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

caridea-dispatch
================

[](#caridea-dispatch)

Caridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.

[![](https://camo.githubusercontent.com/3a9d2bd9abd336c1541d254cd07f8dff935288ad4a0983294f0b3f572f5b0f4b/687474703a2f2f6c69627265776f726b732e636f6d2f636172696465612d3130302e706e67)](https://camo.githubusercontent.com/3a9d2bd9abd336c1541d254cd07f8dff935288ad4a0983294f0b3f572f5b0f4b/687474703a2f2f6c69627265776f726b732e636f6d2f636172696465612d3130302e706e67)

This is its [PSR-7](http://www.php-fig.org/psr/psr-7/) and [PSR-15](http://www.php-fig.org/psr/psr-15/) compliant request handler, with a few middleware implementations.

[![Packagist](https://camo.githubusercontent.com/ad4c4159d0686ad322e7f64131a660b9ec1fad448b8602ad13bdb58ceb0d728c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636172696465612f64697370617463682e737667)](https://packagist.org/packages/caridea/dispatch)[![Build Status](https://camo.githubusercontent.com/f713cf1947636d55c97baaec9158c926d086e7e2c03632f035e64163615b96db/68747470733a2f2f7472617669732d63692e6f72672f6c69627265776f726b732f636172696465612d64697370617463682e737667)](https://travis-ci.org/libreworks/caridea-dispatch)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/32d91bc1d20302314efd28a35e281f71e2fa2233a8bf896e2066f7cbc0fa5350/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c69627265776f726b732f636172696465612d64697370617463682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/libreworks/caridea-dispatch/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/afd27240ec69c8ceaf0e4a12523b17fafaee015f4fcb26236392c17264a7debd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c69627265776f726b732f636172696465612d64697370617463682f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/libreworks/caridea-dispatch/?branch=master)[![Documentation Status](https://camo.githubusercontent.com/c9caa7b1d71c7d0f8c281172b4936e7a797744447a99dbc47513b1848d7e665b/687474703a2f2f72656164746865646f63732e6f72672f70726f6a656374732f636172696465612d64697370617463682f62616467652f3f76657273696f6e3d6c6174657374)](http://caridea-dispatch.readthedocs.io/en/latest/?badge=latest)

Installation
------------

[](#installation)

You can install this library using Composer:

```
$ composer require caridea/dispatch
```

- The master branch (version 3.x) of this project requires PHP 7.1 and depends on `psr/http-message`, `psr/http-server-handler`, and `psr/http-server-middleware`.

Compliance
----------

[](#compliance)

Releases of this library will conform to [Semantic Versioning](http://semver.org).

Our code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!

Documentation
-------------

[](#documentation)

- Head over to [Read the Docs](http://caridea-dispatch.readthedocs.io/en/latest/)

Examples
--------

[](#examples)

Just a few quick examples.

### Runner

[](#runner)

You can use the `Runner` to give it some middleware and let it handle your request.

```
$request = new \Zend\Diactoros\ServerRequest();
// I generally use zend-diactoros, but feel free to use whatever PSR-7 library you use

$middleware = [
    // your custom \Psr\Http\Server\MiddlewareInterface objects
];
$runner = new \Caridea\Dispatch\Runner($middleware);
$response = $runner->handle($request);
```

Your final middleware should create and return a PSR-7 `ResponseInterface`. You can also provide one to the `Runner` constructor and it handles it automatically.

```
$response = new \Zend\Diactoros\Response();
$runner = new \Caridea\Dispatch\Runner($middleware, $response);
$response = $runner->handle($request);
```

A `Runner` is immutable. You can use it more than once.

```
$runner = new \Caridea\Dispatch\Runner($middleware);
$response1 = $runner->handle($request);
$response2 = $runner->handle($request);
```

### Priority Runner

[](#priority-runner)

We included an extension of the `MiddlewareInterface`: `Caridea\Dispatch\Middleware\Prioritized`. Using the `Caridea\Dispatch\PriorityRunner`, you can provide middleware out of order, and they get invoked in order of priority.

```
$middleware = [
    // your custom \Psr\Http\Server\MiddlewareInterface objects.
    // Any that implement Prioritized will get run in priority order,
    // Any others get run last, in insert order.
];
$runner = new \Caridea\Dispatch\PriorityRunner($middleware);
```

You can also use the `Caridea\Dispatch\Middleware\PriorityDelegate` class to assign priority to an existing middleware implementation.

```
$middleware = new \Caridea\Dispatch\Middleware\PriorityDelegate($middleware, 123456);
```

### Middleware

[](#middleware)

Middleware implementations we include.

#### Reporter

[](#reporter)

Use the `Caridea\Dispatch\Middleware\Reporter` to capture `Throwable`s, log them, and re-throw the exception. PSR-3 required.

#### Prototype

[](#prototype)

A simple middleware that returns a `ResponseInterface` you provide.

See Also
--------

[](#see-also)

- [This blog post](https://mwop.net/blog/2018-01-23-psr-15.html) from Matthew Weier O'Phinney about why PSR-15 ditched the old pattern of "double pass" middleware with anonymous functions.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3008d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/659262eac941ffe4795493834425fc9a2369c2c9df3cc565ed4194f1d37be934?d=identicon)[doublecompile](/maintainers/doublecompile)

---

Top Contributors

[![doublecompile](https://avatars.githubusercontent.com/u/4267230?v=4)](https://github.com/doublecompile "doublecompile (3 commits)")

---

Tags

psr-7middlewarepsr-15dispatchrequest-handler

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/caridea-dispatch/health.svg)

```
[![Health](https://phpackages.com/badges/caridea-dispatch/health.svg)](https://phpackages.com/packages/caridea-dispatch)
```

###  Alternatives

[relay/relay

A PSR-15 server request handler.

3302.1M85](/packages/relay-relay)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[jimtools/jwt-auth

PSR-15 JWT Authentication middleware, A replacement for tuupola/slim-jwt-auth

20142.3k3](/packages/jimtools-jwt-auth)[segrax/open-policy-agent

Open Policy Agent client and PSR-7, PSR-15 Authorization Middleware

212.0k](/packages/segrax-open-policy-agent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
