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

ActiveLibrary

phoole/middleware
=================

Slim and simple PSR-15 compliant middleware runner library for PHP

1.1.0(6y ago)42.3k↓100%Apache-2.0PHPPHP &gt;=7.2.0

Since Oct 21Pushed 6y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

middleware
==========

[](#middleware)

[![Build Status](https://camo.githubusercontent.com/32e03a8f1e6f7264d3e73f0af9298e1dbb197d85bad7500ca69739da74168c02/68747470733a2f2f7472617669732d63692e636f6d2f70686f6f6c652f6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/phoole/middleware)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7e62d603ee0635e2b356c78e67d0f4d578e296fe5ec8a5f442c7cb303eff286e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70686f6f6c652f6d6964646c65776172652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phoole/middleware/?branch=master)[![Code Climate](https://camo.githubusercontent.com/e6d972439133a80c348cef8ec1f2b2101b080a6396ca0607c348747441c67fc7/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f70686f6f6c652f6d6964646c65776172652f6261646765732f6770612e737667)](https://codeclimate.com/github/phoole/middleware)[![PHP 7](https://camo.githubusercontent.com/4be4976845d0d40a182d0dac85529dd56c8169def2a3faaae39832b2fad2a002/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70686f6f6c652f6d6964646c6577617265)](https://packagist.org/packages/phoole/middleware)[![Latest Stable Version](https://camo.githubusercontent.com/f0b9b644d22b13e4850448f20e5e141dd83ed3e4394947080e0d42392746087f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f70686f6f6c652f6d6964646c6577617265)](https://packagist.org/packages/phoole/middleware)![License](https://camo.githubusercontent.com/ad1696f6c1938b3d4a14a6ab096b3b65835bbccac3ccedbc36ebf661ae3db2c0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686f6f6c652f6d6964646c6577617265)

Slim and simple PSR-15 compliant middleware runner library for PHP.

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

[](#installation)

Install via the `composer` utility.

```
composer require "phoole/middleware"
```

or add the following lines to your `composer.json`

```
{
    "require": {
       "phoole/middleware": "1.*"
    }
}
```

Features
--------------------------------------------

[](#features)

- Able to use PSR-15 compliant middlewares out there.
- Able to use a middleware [queue](#queue) (a group of middlewares) as a generic middleware in another(or the main) queue.

Usage
-----

[](#usage)

Create the middleware queue, then process all the middlewares.

```
use Phoole\Middleware\Queue;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;

// create middleware queue with 404 response as default(last)
$mws = new Queue(new Response(404));

// add middlewares
$mws->add(
    new LoggerMiddleware(),
    new DispatcherMiddleware()
);

// process the request with middlewares
$response = $mws->handle(new ServerRequest('GET', 'http://bingo.com/get'));
```

Advanced
--------

[](#advanced)

- Subqueue

    `Phoole\Middleware\Queue` implements the `Psr\Http\Server\MiddlewareInterface`, so the queue itself can be used as a generic middleware.

    ```
    // subqueue may need no default response if not the last in the main queue
    $subQueue = (new Queue())->add(
        new ResponseTimeMiddleware(),
        new LoggingMiddleware()
    );

    // main middleware queue
    $mws = (new Queue(new Response(404)))->add(
        $subQueue,
        new DispatcherMiddleware()
    );
    ```

Testing
-------

[](#testing)

```
$ composer test
```

Dependencies
------------

[](#dependencies)

- PHP &gt;= 7.2.0
- phoole/base 1.\*
- A PSR-7 HTTP message implementation, such as [guzzle/psr7](https://github.com/guzzle/psr7).

License
-------

[](#license)

- [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~7 days

Total

5

Last Release

2363d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bae7d5f135e90fd05271574bfd04d4844169bd4c554eaa9e103e4af69267ffc?d=identicon)[phoole](/maintainers/phoole)

---

Top Contributors

[![phossa](https://avatars.githubusercontent.com/u/8499165?v=4)](https://github.com/phossa "phossa (7 commits)")[![phoole](https://avatars.githubusercontent.com/u/55728163?v=4)](https://github.com/phoole "phoole (1 commits)")

---

Tags

middlewarephoolephppsr-15psr-7swoolephpmiddlewarelibraryswoolephoole

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[hyperf/hyperf-skeleton

A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.

301187.4k](/packages/hyperf-hyperf-skeleton)

PHPackages © 2026

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