PHPackages                             slince/middleware - 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. slince/middleware

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

slince/middleware
=================

A flexible PSR15 middleware dispatcher

2.0.1(6y ago)17281MITPHPPHP &gt;=7.0

Since May 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/slince/middleware)[ Packagist](https://packagist.org/packages/slince/middleware)[ RSS](/packages/slince-middleware/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (4)Used By (0)

Middleware Dispatcher
=====================

[](#middleware-dispatcher)

[![Build Status](https://camo.githubusercontent.com/dd3f745d1dc81088367487be8c9043e84bf8bf6a18e5a57c6d1dd1cfa62a89aa/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736c696e63652f6d6964646c65776172652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/slince/middleware)[![Coverage Status](https://camo.githubusercontent.com/774576bb2f6e24b30f75f5b6cbf2c071a82609795654c6f8c1b28e1e756b9e2b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f736c696e63652f6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/slince/middleware)[![Latest Stable Version](https://camo.githubusercontent.com/19e43bce1d8143c63d968bbf3159d0a698ce86ec6d6a5e98d7b0cde8e294d93a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c696e63652f6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/slince/middleware)[![Scrutinizer](https://camo.githubusercontent.com/03128dbe65842727a907638e1ec117b907730e89d035b9168da31d978d914924/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736c696e63652f6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slince/middleware/?branch=master)

The package is a flexible PSR-15 middleware dispatcher for PSR-7 request message that help to create middlewares and dispatch.

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

[](#installation)

Install via composer

```
composer require slince/middleware
```

Quick example
-------------

[](#quick-example)

```
$dispatcher = new Slince\Middleware\Dispatcher([$middleware1, $middleware2]);

$response = $dispatcher->process(Zend\Diactoros\ServerRequestFactory::fromGlobals());

var_dump($response instanceof Psr\Http\Message\ResponseInterface);
```

Usage
-----

[](#usage)

### Add middleware

[](#add-middleware)

Add PSR-15 middlewares to the queue

```
use Psr\Http\Message\ServerRequestInterface;
use Interop\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response;

class MyMiddleware implements MiddlewareInteface
{
    public function process(ServerRequestInterface $request, RequestHandlerInterface $next)
    {
        $response = new Response();
        $response->getBody()->write('hello world');
        return $response;
    }
}
$dispatcher = new Slince\Middleware\Dispatcher([
    new MyMiddleware()
]);
```

Or add a callable function directly

```
$dispatcher->push(function(ServerRequestInterface $request, RequestHandlerInterface $next){
    return $delegate->process($request);
});
```

### Dispatch

[](#dispatch)

```
try {
    $response = $dispatcher->process(Zend\Diactoros\ServerRequestFactory::fromGlobals());
} catch (Slince\Middleware\Exception\MissingResponseException $exception) {
    //...
}
```

A `MissingResponseException` will be thrown if the middleware did not return a invalid response or the queue was exhausted

License
-------

[](#license)

The MIT license. See [MIT](https://opensource.org/licenses/MIT)

###  Health Score

29

—

LowBetter than 63% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~351 days

Total

3

Last Release

2517d ago

Major Versions

1.0.0 → 2.0.02018-01-09

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd286cb3afc4855b71164f536b980931c1944632ad8586cfe0f87bc97afdf8b6?d=identicon)[slince](/maintainers/slince)

---

Top Contributors

[![slince](https://avatars.githubusercontent.com/u/3785826?v=4)](https://github.com/slince "slince (12 commits)")

---

Tags

dispatcherhttphttp-messagesmiddlewaremiddleware-dispatcherspsr-15psr-7httppsr-7middlewarepsr-15middlewaresMiddleware Dispatcher

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/slince-middleware/health.svg)

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

###  Alternatives

[psr/http-server-middleware

Common interface for HTTP server-side middleware

18187.6M1.3k](/packages/psr-http-server-middleware)[mezzio/mezzio

PSR-15 Middleware Microframework

3883.5M88](/packages/mezzio-mezzio)[middlewares/utils

Common utils for PSR-15 middleware packages

503.4M89](/packages/middlewares-utils)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M22](/packages/mezzio-mezzio-authentication)

PHPackages © 2026

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