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

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

componenta/middleware-factory
=============================

PSR-15 middleware factory integration for Componenta

v1.0.0(1mo ago)083MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/componenta/middleware-factory)[ Packagist](https://packagist.org/packages/componenta/middleware-factory)[ RSS](/packages/componenta-middleware-factory/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (3)

Componenta Middleware Factory
=============================

[](#componenta-middleware-factory)

PSR-15 middleware resolver and group factory.

Use this package when routes, modules, or config files need to describe middleware as class names, service ids, callables, existing middleware instances, or named groups, while the runtime always receives concrete `MiddlewareInterface` instances.

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

[](#installation)

```
composer require componenta/middleware-factory
```

The package declares `Componenta\Http\Middleware\ConfigProvider` in `extra.componenta.config-providers`. When `componenta/composer-plugin` is installed, the provider is added to the generated provider list automatically.

Requirements
------------

[](#requirements)

- PHP 8.4+
- PSR-11 container
- PSR-15 HTTP server middleware

Related Packages
----------------

[](#related-packages)

PackageWhy it matters here`componenta/router`Stores route middleware as strings, classes, or groups and passes them to this factory.`componenta/pipeline`Executes created middleware as a PSR-15 chain.`componenta/di`Resolves middleware by service id or class name.`componenta/http-*-middleware`Provides concrete HTTP middleware packages that this factory can resolve through attributes and aliases.Middleware Definitions
----------------------

[](#middleware-definitions)

`MiddlewareFactory` resolves a definition into PSR-15 middleware:

```
use Componenta\Http\Middleware\MiddlewareFactory;

$middleware = $factory->create(AuthMiddleware::class);
$middleware = $factory->create($callable);
$middleware = $factory->create('web');
```

Supported definitions:

- existing `MiddlewareInterface` instances
- PSR-11 service ids or class names
- callables adapted to middleware
- legacy request handler callables
- configured middleware group names

If no resolver can handle a definition, `MiddlewareResolutionException` is thrown with the original definition type.

Resolver Chain
--------------

[](#resolver-chain)

Resolution is delegated to `MiddlewareResolverInterface` implementations:

- `ClassNameResolver`
- `CallableResolver`
- `LegacyCallableResolver`
- `MiddlewareGroupResolver`
- `CompositeResolver`

`CompositeResolver` tries resolvers in order and returns the first successful result. This keeps custom resolution rules additive: register a resolver before or after the defaults depending on precedence.

Groups
------

[](#groups)

`MiddlewareGroup` is a named ordered collection:

```
$group = new MiddlewareGroup('web', [
    SessionMiddleware::class,
    CsrfMiddleware::class,
]);

$pipeline = $factory->createGroup($group);
```

Groups are useful when route config should refer to a stable name like `web`, `api`, or `admin` without duplicating the middleware list.

Config
------

[](#config)

`ConfigProvider` registers the factory and default resolvers. `ConfigKey` contains keys for middleware groups and resolver definitions.

Applications can replace or extend the resolver chain by changing DI config rather than changing route definitions.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

43d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20490712?v=4)[Andrey Shelamkoff](/maintainers/Shelamkoff)[@Shelamkoff](https://github.com/Shelamkoff)

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

### Embed Badge

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

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k17](/packages/tempest-framework)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[mezzio/mezzio

PSR-15 Middleware Microframework

3923.8M126](/packages/mezzio-mezzio)

PHPackages © 2026

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