PHPackages                             cormy/server-middleware-dispatcher - 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. cormy/server-middleware-dispatcher

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

cormy/server-middleware-dispatcher
==================================

Cormy PSR-7 server middleware dispatcher

0.1.0(9y ago)0782MITPHPPHP &gt;=7

Since Nov 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/cormy/server-middleware-dispatcher)[ Packagist](https://packagist.org/packages/cormy/server-middleware-dispatcher)[ RSS](/packages/cormy-server-middleware-dispatcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (2)Used By (2)

Cormy Server Middleware Dispatcher [![Build Status](https://camo.githubusercontent.com/4eeed80d4d23f0f68a2aa6bb317d70abd92f758beb9a2c4816aa38a154a30f64/68747470733a2f2f7472617669732d63692e6f72672f636f726d792f7365727665722d6d6964646c65776172652d646973706174636865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cormy/server-middleware-dispatcher) [![Coverage Status](https://camo.githubusercontent.com/252d001bb3e953e8718a15576cc38ca38d8975553913ad570b97fedf1afd7cf1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f636f726d792f7365727665722d6d6964646c65776172652d646973706174636865722f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/cormy/server-middleware-dispatcher?branch=master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/4821a52f86788e0cdddba3ba6be26a2db3d5ab5e9ced6e88545e171e82b905ed/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f726d792f7365727665722d6d6964646c65776172652d646973706174636865722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cormy/server-middleware-dispatcher/?branch=master)
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#cormy-server-middleware-dispatcher---)

[![SensioLabsInsight](https://camo.githubusercontent.com/5537e0a0f569422de2b142c3616aa3413017b6b16a310b4349d37dc39a982323/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f36353338363064662d373930332d343731312d393862332d6336306533343966316536352f6269672e706e67)](https://insight.sensiolabs.com/projects/653860df-7903-4711-98b3-c60e349f1e65)

> 🔩 Cormy [PSR-7](http://www.php-fig.org/psr/psr-7) server middleware dispatcher

Install
-------

[](#install)

```
composer require cormy/server-middleware-dispatcher

```

Usage
-----

[](#usage)

```
use Cormy\Server\MiddlewareDispatcher;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

$middleware = function (ServerRequestInterface $request):\Generator {
    // delegate $request to the next request handler, i.e. the $finalHandler below
    $response = (yield $request);

    return $response->withHeader('X-PoweredBy', 'Unicorns');
};

$finalHandler = function (ServerRequestInterface $request):ResponseInterface {
    return new \Zend\Diactoros\Response();
};

// create a dispatcher
$dispatcher = new MiddlewareDispatcher($middleware, $finalHandler);

// dispatch a request
$response = $dispatcher(new \Zend\Diactoros\ServerRequest());
```

API
---

[](#api)

### `Cormy\Server\MiddlewareDispatcher implements Cormy\Server\RequestHandlerInterface`

[](#cormyservermiddlewaredispatcher-implements-cormyserverrequesthandlerinterface)

#### `MiddlewareDispatcher::__construct`

[](#middlewaredispatcher__construct)

```
/**
 * Create a Cormy PSR-7 server middleware dispatcher.
 *
 * @param callable|MiddlewareInterface     $middleware
 * @param callable|RequestHandlerInterface $finalHandler
 */
public function __construct(callable $middleware, callable $finalHandler)
```

#### Inherited from [`Cormy\Server\RequestHandlerInterface::__invoke`](https://github.com/cormy/server-request-handler)

[](#inherited-from-cormyserverrequesthandlerinterface__invoke)

```
/**
 * Process an incoming server request and return the response.
 *
 * @param ServerRequestInterface $request
 *
 * @return ResponseInterface
 */
public function __invoke(ServerRequestInterface $request):ResponseInterface;
```

Related
-------

[](#related)

- [Cormy\\Server\\Onion](https://github.com/cormy/onion) – Onion style PSR-7 **middleware stack** using generators
- [Cormy\\Server\\Bamboo](https://github.com/cormy/bamboo) – Bamboo style PSR-7 **middleware pipe** using generators
- [Cormy\\Server\\RequestHandlerInterface](https://github.com/cormy/server-request-handler) – Common interfaces for PSR-7 server request handlers
- [Cormy\\Server\\MiddlewareInterface](https://github.com/cormy/server-middleware) – Common interfaces for Cormy PSR-7 server middlewares

License
-------

[](#license)

MIT © [Michael Mayer](http://schnittstabil.de)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

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

3454d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6059032?v=4)[Michael Mayer](/maintainers/schnittstabil)[@schnittstabil](https://github.com/schnittstabil)

---

Top Contributors

[![schnittstabil](https://avatars.githubusercontent.com/u/6059032?v=4)](https://github.com/schnittstabil "schnittstabil (2 commits)")

---

Tags

httpresponserequestpsrpsr-7http-messagemiddlewareserverdispatchercormy

### Embed Badge

![Health badge](/badges/cormy-server-middleware-dispatcher/health.svg)

```
[![Health](https://phpackages.com/badges/cormy-server-middleware-dispatcher/health.svg)](https://phpackages.com/packages/cormy-server-middleware-dispatcher)
```

###  Alternatives

[psr/http-server-handler

Common interface for HTTP server-side request handler

175101.3M918](/packages/psr-http-server-handler)[psr/http-server-middleware

Common interface for HTTP server-side middleware

18091.2M1.5k](/packages/psr-http-server-middleware)[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39489.0M272](/packages/fig-http-message-util)[idealo/php-middleware-stack

Implementation of HTTP Middleware PSR-15 specification

318.9k](/packages/idealo-php-middleware-stack)[art4/requests-psr18-adapter

Use WordPress/Requests as a PSR-18 HTTP client

153.3k](/packages/art4-requests-psr18-adapter)

PHPackages © 2026

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