PHPackages                             ericabouaf/middl - 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. ericabouaf/middl

ActiveLibrary[Framework](/categories/framework)

ericabouaf/middl
================

A generic implementation of the middleware pattern in PHP

v1.0.0(1y ago)038PHP

Since Aug 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ericabouaf/php-middl)[ Packagist](https://packagist.org/packages/ericabouaf/middl)[ RSS](/packages/ericabouaf-middl/feed)WikiDiscussions main Synced 1mo ago

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

Middl
=====

[](#middl)

A generic implementation of the middleware pattern in PHP

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

[](#installation)

```
composer require ericabouaf/middl
```

Usage
-----

[](#usage)

### Middleware Configuration

[](#middleware-configuration)

To configure the middlewares, you need to create a class that extends `AbstractFlow` and implements the `configureMiddlewares` method.

```
use YourNamespace\AbstractFlow;
use YourNamespace\Middleware\DummyMiddleware;

class SampleFlow extends AbstractFlow
{
    protected function configureMiddlewares(): array
    {
        return [
            new DummyMiddleware('example'),
            // Add other middlewares here
        ];
    }
}
```

### Creating a Middleware

[](#creating-a-middleware)

To create a middleware, you can extend `AbstractMiddleware` or `BeforeAfterMiddleware` according to your needs.

#### Example with `AbstractMiddleware`

[](#example-with-abstractmiddleware)

```
use YourNamespace\AbstractMiddleware;
use YourNamespace\Request;
use YourNamespace\Response;

class SampleCustomMiddleware extends AbstractMiddleware
{
    public function __invoke(Request $request, callable $next): Response
    {
        // Middleware logic before calling the next middleware
        $response = $next($request);
        // Middleware logic after calling the next middleware
        return $response;
    }
}
```

#### Example with `BeforeAfterMiddleware`

[](#example-with-beforeaftermiddleware)

```
use YourNamespace\Middleware\BeforeAfterMiddleware;
use YourNamespace\Request;
use YourNamespace\Response;

class SampleBeforeAfterMiddleware extends BeforeAfterMiddleware
{
    public function before(Request $request): void
    {
        // Logic before calling the next middleware
    }

    public function after(Request $request, Response $response): Response
    {
        // Logic after calling the next middleware
        return $response;
    }
}
```

### Executing the Middlewares without a Flow

[](#executing-the-middlewares-without-a-flow)

To execute the middlewares, use the `run` method of the `MiddlewareRunner` class.

```
use YourNamespace\MiddlewareRunner;
use YourNamespace\Request;
use YourNamespace\Response;
use Psr\Log\NullLogger;

$request = new Request(['param1' => 'value1']);
$middlewares = [
    new SampleCustomMiddleware(),
    new SampleBeforeAfterMiddleware(),
    // Add other middlewares here
];

$response = MiddlewareRunner::run($middlewares, $request, new NullLogger());
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

632d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b07b937c4c01181b6dbe7e5ac025637f0a2cc639d26a6cd6efe40260f7c20bb?d=identicon)[neyric](/maintainers/neyric)

---

Top Contributors

[![ericabouaf](https://avatars.githubusercontent.com/u/39354?v=4)](https://github.com/ericabouaf "ericabouaf (11 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ericabouaf-middl/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[laravel/nightwatch

The official Laravel Nightwatch package.

3486.1M13](/packages/laravel-nightwatch)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)

PHPackages © 2026

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