PHPackages                             thecodingmachine/middleware-list-universal-module - 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. thecodingmachine/middleware-list-universal-module

ActiveLibrary

thecodingmachine/middleware-list-universal-module
=================================================

Cross-framework module providing a service containing a list of middlewares

v1.1.1(7y ago)3182.1k↓50%37MITPHPPHP &gt;=7.0

Since Mar 2Pushed 7y ago8 watchersCompare

[ Source](https://github.com/thecodingmachine/middleware-list-universal-module)[ Packagist](https://packagist.org/packages/thecodingmachine/middleware-list-universal-module)[ RSS](/packages/thecodingmachine-middleware-list-universal-module/feed)WikiDiscussions 1.1 Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (7)Used By (7)

http-interop middleware list universal module
=============================================

[](#http-interop-middleware-list-universal-module)

This package simply providers an http-interop middleware list to any [container-interop](https://github.com/container-interop/service-provider) compatible framework/container. The middleware list is **empty**. Any package can come and add a middleware to the list.

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

[](#installation)

This package is typically used by packages providing middlewares.

```
composer require thecodingmachine/middleware-list-universal-module

```

If your container supports autodiscovery by thecodingmachine/discovery, there is nothing more to do. Otherwise, you need to register the [`TheCodingMachine\MiddlewareListServiceProvider`](src/MiddlewareListServiceProvider.php) into your container.

Refer to your framework or container's documentation to learn how to register *service providers*.

Usage
-----

[](#usage)

The middleware queue is registered under the key `MiddlewareListServiceProvider::MIDDLEWARES_QUEUE`. This is a `\SPLPriorityQueue`.

Depending on the middleware you are registering, you generally have a fairly good idea of the order it should run compared to other middlewares.

Let's split the middlewares in 4 families:

- **Utility middlewares**: those are typically handled at the beginning of a request. They are used to modify/enrich the response and pass it to other middlewares. In this category, you would put middlewares that compute the response time, middlewares that add geolocation information, middlewares that manage sessions, etc...
- **Routers**: those are middlewares that are typically used to handle a request and return a response. They respond on specific routes or pass the request along to the next router if they don't know that route.
- **Page not found routers**: those are middlewares in charge of answering a 404 answer if no middleware has handled the request. This is the last "classical" middleware of the queue.
- **Error handling middlewares**: Finally, at the very end of the queue, you will find the list of middlewares that handle errors and exceptions. They are in charge of logging or displaying error messages.

Based on those 4 families, the `MiddlewareListServiceProvider` provides a SPL Priority Queue that one can use to register any middleware at the right point in the queue.

The service provider defines 12 constants you can use to insert a middleware at a given point:

- `MiddlewareOrder::EXCEPTION_EARLY` (3050)
- `MiddlewareOrder::EXCEPTION` (3000)
- `MiddlewareOrder::EXCEPTION_LATE` (2950)
- `MiddlewareOrder::UTILITY_EARLY` (2050)
- `MiddlewareOrder::UTILITY` (2000)
- `MiddlewareOrder::UTILITY_LATE` (1950)
- `MiddlewareOrder::ROUTER_EARLY` (1050)
- `MiddlewareOrder::ROUTER` (1000)
- `MiddlewareOrder::ROUTER_LATE` (950)
- `MiddlewareOrder::PAGE_NOT_FOUND_EARLY` (50)
- `MiddlewareOrder::PAGE_NOT_FOUND` (0)
- `MiddlewareOrder::PAGE_NOT_FOUND_LATE` (-50)

Each "family" has 3 variants: EARLY, NORMAL and LATE, so you can add more fine grained tuning if you want a utility to be triggered before another one, etc...

So if you want to register a middleware, you would typically write:

```
$middlewareQueue = $container->get(MiddlewareListServiceProvider::MIDDLEWARES_QUEUE);
/* @var $middlewareQueue \SplPriorityQueue */
$middlewareQueue->insert($myMiddleware, MiddlewareOrder::UTILITY);
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

Recently: every ~83 days

Total

7

Last Release

2904d ago

Major Versions

v0.2.0 → 1.0.x-dev2017-07-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

![](https://avatars.githubusercontent.com/u/1847918?v=4)[TheCodingMachine](/maintainers/thecodingmachine)[@thecodingmachine](https://github.com/thecodingmachine)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (8 commits)")[![xhuberty](https://avatars.githubusercontent.com/u/8350192?v=4)](https://github.com/xhuberty "xhuberty (1 commits)")

### Embed Badge

![Health badge](/badges/thecodingmachine-middleware-list-universal-module/health.svg)

```
[![Health](https://phpackages.com/badges/thecodingmachine-middleware-list-universal-module/health.svg)](https://phpackages.com/packages/thecodingmachine-middleware-list-universal-module)
```

###  Alternatives

[mnapoli/simplex

Pimple fork with full container-interop support

13123.1k16](/packages/mnapoli-simplex)

PHPackages © 2026

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