PHPackages                             pierotto/symfony-middleware-bundle - 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. pierotto/symfony-middleware-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

pierotto/symfony-middleware-bundle
==================================

This Symfony extension allows for the integration of middleware into your application, providing a streamlined approach to handling HTTP requests and responses.

1.1.0(2y ago)616MITPHPPHP &gt;=8.1

Since Apr 1Pushed 2y ago2 watchersCompare

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

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

Middleware bundle
=================

[](#middleware-bundle)

This Symfony extension makes it possible to implement middleware for editing requests and responses within a Symfony application. Middlewares are registered as services in a container and run in the order they are defined in code.

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

[](#installation)

The package can be installed using Composer with the command::

`$ composer require pierotto/symfony-middleware-bundle`

After installing the package, it needs to be registered in `AppKernel.php`:

```
public function registerBundles(): array
{
    $bundles = [
        new \Pierotto\MiddlewareBundle\MiddlewareBundle(),
    ];
}

```

Usage
-----

[](#usage)

To use middleware, you need to create your own class that implements `\Psr\Http\Server\MiddlewareInterface`. Then this class can be registered as a service in the container and set the middleware tag.

For example, request modification middleware can be implemented as follows:

```
namespace Api\Http\Middleware;

class CustomMiddleware implements \Psr\Http\Server\MiddlewareInterface
{

	public function process(
		\Psr\Http\Message\ServerRequestInterface $request,
		\Psr\Http\Server\RequestHandlerInterface $handler
	): \Psr\Http\Message\ResponseInterface
	{
		return $handler->handle($request->withAttribute('test', 'test'));
	}

}

```

The response editing middleware could look like this:

```
namespace Api\Http\Middleware;

class NotFoundMiddleware implements \Psr\Http\Server\MiddlewareInterface
{

	public function process(
		\Psr\Http\Message\ServerRequestInterface $request,
		\Psr\Http\Server\RequestHandlerInterface $handler
	): \Psr\Http\Message\ResponseInterface
	{
		return new \Nyholm\Psr7\Response\Response(404);
	}

}

```

Then you need to register the created middleware as services in `services.yml` and set the `middleware` tag to them:

```
Api\Http\Middleware\CustomMiddleware:
        tags: [ 'middleware' ]

```

Middleware can then be used when calling controller methods by adding the `\Application\MiddlewareBundle\Infrastructure\Attribute\Middleware` attribute with the value of the middleware class name. The middleware is started in the order in which the attributes are defined.

```
#[\Application\MiddlewareBundle\Infrastructure\Attribute\Middleware(Api\Http\Middleware\CustomMiddleware::class)]
	public function defaultAction(
		\Symfony\Component\HttpFoundation\Request $request
	): \Symfony\Component\HttpFoundation\Response

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

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

Every ~126 days

Total

3

Last Release

881d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62ab7f818b246d72b9ffc8426be8de58a55e0ec1243c6e5e77c2c4cd845d7618?d=identicon)[pierotto](/maintainers/pierotto)

---

Top Contributors

[![pierotto](https://avatars.githubusercontent.com/u/46345782?v=4)](https://github.com/pierotto "pierotto (7 commits)")

---

Tags

middlewaresymfonypsr-15

### Embed Badge

![Health badge](/badges/pierotto-symfony-middleware-bundle/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

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

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

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

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[kafkiansky/symfony-middleware

PSR-15 Middleware for symfony.

7959.6k](/packages/kafkiansky-symfony-middleware)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)

PHPackages © 2026

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