PHPackages                             kapitanluffy/middlewarestack - 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. [Framework](/categories/framework)
4. /
5. kapitanluffy/middlewarestack

ActiveLibrary[Framework](/categories/framework)

kapitanluffy/middlewarestack
============================

Implementing PSR-15 Middlewares in a single class

06PHP

Since Oct 29Pushed 8y ago2 watchersCompare

[ Source](https://github.com/kapitanluffy/middlewarestack)[ Packagist](https://packagist.org/packages/kapitanluffy/middlewarestack)[ RSS](/packages/kapitanluffy-middlewarestack/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Middleware Stack
================

[](#middleware-stack)

Implementing [PSR-15](https://github.com/php-fig/fig-standards/tree/master/proposed/http-middleware) Middlewares in a single class.

###### Why?

[](#why)

As defined in the proposal, middlewares "processes" a request and returns a response. Similarly, RequestHandlers "handles" a request and returns a response. The idea of this package is to simplify the goals of the interfaces provided by PSR-15.

###### Install

[](#install)

```
composer require kapitanluffy/middlewarestack

```

###### Usage

[](#usage)

```
use kapitanluffy\middleware\MiddlewareStack;
use Zend\Diactoros\ServerRequestFactory;

$innerStack = new MiddlewareStack(array(
    new Middlewares\Robots(false),
    new Middlewares\TrailingSlash(false)
));

$stack = new MiddlewareStack(array(
    new Middlewares\Whoops(),

    // Use another stack as middleware
    $innerStack,

    // Create an inner stack with arrays
    array(
        new Middlewares\ResponseTime(),
        new Middlewares\Uuid(),
    ),

    // Create closures as middlewares
    function ($request, $stack) {
        $response = $stack->handle($request);
        return $response->withHeader('X-Passed-MiddlewareClosure', 1);
    }
));

// let the middleware stack handle the request
$request = ServerRequestFactory::fromGlobals();
$response = $stack->handle($request);
```

###### Middlewares

[](#middlewares)

You can find a list of middlewares [here](https://github.com/middlewares) or implement your own by implementing the [MiddlewareInterface](https://github.com/http-interop/http-middleware/blob/master/src/MiddlewareInterface.php)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/94708d8e5552d7869dca34196b0fd8785584117b7f3d534abd849ab574da70ab?d=identicon)[kapitanluffy](/maintainers/kapitanluffy)

---

Top Contributors

[![kapitanluffy](https://avatars.githubusercontent.com/u/485799?v=4)](https://github.com/kapitanluffy "kapitanluffy (9 commits)")

### Embed Badge

![Health badge](/badges/kapitanluffy-middlewarestack/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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