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

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

noglitchyo/symfony-middleware-bundle
====================================

Introduce PSR-15 middleware collection dispatcher into Symfony.

0.1.0(6y ago)410MITPHPPHP &gt;=7.3

Since Jul 13Pushed 6y agoCompare

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

READMEChangelog (1)Dependencies (12)Versions (3)Used By (0)

symfony-middleware-bundle
=========================

[](#symfony-middleware-bundle)

Introduces PSR-15 middleware support into Symfony framework.

[![PHP from Packagist](https://camo.githubusercontent.com/63e27d2f50bc4ea7e2d45b826fc47447a48504d7cfaf45d7c8d7049e3029b838/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e737667)](https://camo.githubusercontent.com/63e27d2f50bc4ea7e2d45b826fc47447a48504d7cfaf45d7c8d7049e3029b838/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e737667)[![Build Status](https://camo.githubusercontent.com/2781346ee3e75bdc5f4d013adc61b118f628b67a44d0528cac0543ab358f609b/68747470733a2f2f7472617669732d63692e6f72672f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/noglitchyo/symfony-middleware-bundle)[![codecov](https://camo.githubusercontent.com/6d3bbd3cc360bba0e29b8af576cbd477aa81b044b7e0a707a8055596523f54f3/68747470733a2f2f636f6465636f762e696f2f67682f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/noglitchyo/symfony-middleware-bundle)[![Scrutinizer code quality (GitHub/Bitbucket)](https://camo.githubusercontent.com/9b4a552bcfbdffc7003448ad71c078aa95c3ec6c75e3519d1cfd06e0387888fc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e737667)](https://camo.githubusercontent.com/9b4a552bcfbdffc7003448ad71c078aa95c3ec6c75e3519d1cfd06e0387888fc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e737667)[![Packagist](https://camo.githubusercontent.com/7a67fbe11ffb5eb1bd970c551a9c584e7405c0798d48705517a56eac50dfc714/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e737667)](https://camo.githubusercontent.com/7a67fbe11ffb5eb1bd970c551a9c584e7405c0798d48705517a56eac50dfc714/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f676c69746368796f2f73796d666f6e792d6d6964646c65776172652d62756e646c652e737667)

Roadmap
=======

[](#roadmap)

- Full test coverage
- Documentation

This bundle is under heavy development and is not meant to be used in production. Feel free to contribute!

Description
===========

[](#description)

Symfony Middleware Bundle provides support for PSR-15 middleware execution in Symfony application. It introduces a middleware dispatcher in a non-intrusive way, so it can be used with a minimal and simple configuration.

This bundle attempts to offer two implementations, so it can be used in different ways:

- through an event listener plugged on the events dispatched by the HttpKernel. It will execute the middleware collection before passing the request to the controller if no response were created by the middlewares.
- as a decorator of the HttpKernel with the MiddlewareStackKernel.

Getting started
===============

[](#getting-started)

Requirements
============

[](#requirements)

- Symfony 4
- PHP 7.3

Installation
============

[](#installation)

Applications that use Symfony Flex
----------------------------------

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

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

Applications that don't use Symfony Flex
----------------------------------------

[](#applications-that-dont-use-symfony-flex)

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

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

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    NoGlitchYo\MiddlewareBundle\NoGlitchYoMiddlewareBundle::class => ['all' => true],
];
```

Usage
=====

[](#usage)

#### Step 1: Create a middleware collection

[](#step-1-create-a-middleware-collection)

First, it is required to define a middleware collection. The middleware collection will, as states its name, contains all the middleware to execute.

For this purpose, this bundle rely on the middleware collection implementation from [noglitchyo/middleware-collection-request-handler](https://github.com/noglitchyo/middleware-collection-request-handler)which gives the ability to execute a collection of middlewares as if it was a single PSR-15 middleware or request handler with different execution strategies.

#### Example

[](#example)

`services.yaml`

```
  # Let's define some middlewares that we want to use.
  App\Middleware\SecurityMiddleware: ~
  App\Middleware\CorsMiddleware: ~
  App\Middleware\RouterMiddleware: ~*

  # Then, we define the middleware
  middleware_collections.default:
    class: NoGlitchYo\MiddlewareCollectionRequestHandler\Collection\MiddlewareCollectionInterface
        # Define the middleware collection class which MUST implement MiddlewareCollectionInterface.
        # Some default implementations are provided. Choose one of them or create your own.
        # NoGlitchYo\MiddlewareCollectionRequestHandler\Collection\ArrayStackMiddlewareCollection
        # NoGlitchYo\MiddlewareCollectionRequestHandler\Collection\SplQueueMiddlewareCollection
        # NoGlitchYo\MiddlewareCollectionRequestHandler\Collection\SplStackMiddlewareCollection
    arguments:
      - ['@App\Middleware\EncoderMiddleware', '@App\Middleware\RouterMiddleware', '@App\Middleware\EncoderMiddleware']
    tags: ['middlewares.collection'] # Tag it! So the collection can be picked up.
```

#### Step 2: Define a middleware handler

[](#step-2-define-a-middleware-handler)

Handler gives the instruction to execute the attached middleware collection. Once, it is defined, the collection of middlewares will be executed for every incoming requests.

It is possible to define some conditions on when the handler should be run:

- Route Path matching : if the route path of the request match the given route path
- Route Name matching : if the route name of the request match the given route name

#### Example

[](#example-1)

`middlewares.yaml`

```
middlewares:
  handlers:
    default: # Name of your handler configuration
      collection: default.middleware_collection # should be the collection class name / service name defined in services.yaml
      condition: # Condition is optional, if not provided the collection will be executed for every requests
        routePath: '/path/test/1'
        routeName: 'myCustomRouteName'
```

Tests
=====

[](#tests)

Would like to the run the test suite? Go ahead:

`composer test`

References
==========

[](#references)

License
=======

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

2537d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5823bcfba95933f99e94e241cbd3f5c22cec877d24b8c9f602bf44c4cd821cd5?d=identicon)[noglitchyo](/maintainers/noglitchyo)

---

Top Contributors

[![noglitchyo](https://avatars.githubusercontent.com/u/764791?v=4)](https://github.com/noglitchyo "noglitchyo (20 commits)")

---

Tags

dispatchermiddlewarepsr-15psr-7request-handlersymfonyhttppsr-7http-messagemiddlewaresymfonystackhandlerpsr-15Bridgedispatcher

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k181.3M2.2k](/packages/symfony-security-bundle)

PHPackages © 2026

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