PHPackages                             thecodingmachine/drupal-stratigility-bridge - 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. thecodingmachine/drupal-stratigility-bridge

ActiveDrupal-module

thecodingmachine/drupal-stratigility-bridge
===========================================

This Drupal 8 module provides a bridge to include PSR-15 middlewares through Stratigility.

1.0.x-dev(7y ago)111.8k1MITPHPPHP &gt;=7.0

Since Dec 7Pushed 7y ago7 watchersCompare

[ Source](https://github.com/thecodingmachine/drupal-stratigility-bridge)[ Packagist](https://packagist.org/packages/thecodingmachine/drupal-stratigility-bridge)[ RSS](/packages/thecodingmachine-drupal-stratigility-bridge/feed)WikiDiscussions 1.0 Synced 2mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

thecodingmachine/drupal-stratigility-bridge
===========================================

[](#thecodingmachinedrupal-stratigility-bridge)

Bridges between [Drupal 8](https://www.drupal.org/8) and PSR-15 middleware modules through the use of [Zend Framework's Stratigility](https://zendframework.github.io/zend-stratigility/).

[![Latest Stable Version](https://camo.githubusercontent.com/d44ca9b04221f7c83467fc48d97c8ca2ee212641c36810875f207f621b4f156a/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f64727570616c2d73747261746967696c6974792d6272696467652f762f737461626c65)](https://packagist.org/packages/thecodingmachine/drupal-stratigility-bridge)[![Total Downloads](https://camo.githubusercontent.com/a9ea8a035ff9ac9419a6b729e8a6c1435e82c6603afd9a2aa5f2577924c1c2af/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f64727570616c2d73747261746967696c6974792d6272696467652f646f776e6c6f616473)](https://packagist.org/packages/thecodingmachine/drupal-stratigility-bridge)[![Latest Unstable Version](https://camo.githubusercontent.com/8bba54e39484c9ed3666a3006591fd0604b6a4d4ad64423c24a180cf9a1c7c7b/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f64727570616c2d73747261746967696c6974792d6272696467652f762f756e737461626c65)](https://packagist.org/packages/thecodingmachine/drupal-stratigility-bridge)[![License](https://camo.githubusercontent.com/1a27680965b32690ab11ff66655506cf5bcd9a078ffdabb5f63323a47fdae370/68747470733a2f2f706f7365722e707567782e6f72672f746865636f64696e676d616368696e652f64727570616c2d73747261746967696c6974792d6272696467652f6c6963656e7365)](https://packagist.org/packages/thecodingmachine/drupal-stratigility-bridge)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c19c0a4fd3bb23e962a4f33b1c2c28f85abf95b2d91f10d799d583889ad39811/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746865636f64696e676d616368696e652f64727570616c2d73747261746967696c6974792d6272696467652f6261646765732f7175616c6974792d73636f72652e706e673f623d312e30)](https://scrutinizer-ci.com/g/thecodingmachine/drupal-stratigility-bridge/?branch=1.0)

> Version 1.0 allows you to use PSR-15 middlewares in Drupal 8. Versions 0.x are bridges with the now deprecated http-interop middlewares.

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

[](#installation)

This project is a Drupal 8 module.

The recommended way to install drupal-stratigility-bridge is through [Composer](http://getcomposer.org/):

```
composer require thecodingmachine/drupal-stratigility-bridge
```

Usage
-----

[](#usage)

This module will fill the Drupal container with a new `stratigility_pipe` entry (it is a `Zend\Stratigility\MiddlewarePipe`).

You can extend this entry in your own module to register a new middleware.

In Drupal services, you can simply add the `psr15_middleware` to your middleware service. This will automatically register the middleware in Stratigility's pipe.

So your `MYMODULE.services.yml` will certainly look like this:

```
services:
  my_middleware:
    class:      Acme\MyMiddleware
    tags:
      - { name: psr15_middleware }
```

Using Drupal render arrays in PSR-15 middlewares
------------------------------------------------

[](#using-drupal-render-arrays-in-psr-15-middlewares)

This module comes with a service that let's you [render Drupal "arrays"](https://www.drupal.org/docs/8/api/render-api/render-arrays).

To do so, simply inject the `drupal_array_render_caller` service in your controller and call the `getResponse` method.

Below is a sample middleware that returns a "Hello world!" Drupal page when the "/foo" page is hit:

```
class HelloWorldMiddleware implements MiddlewareInterface
{
    /**
     * @var DrupalArrayRenderCaller
     */
    private $arrayRenderCaller;

    public function __construct(DrupalArrayRenderCaller $arrayRenderCaller)
    {
        $this->arrayRenderCaller = $arrayRenderCaller;
    }

    public function process(ServerRequestInterface $request, RequestHandlerInterface $delegate)
    {
        if (trim($request->getUri()->getPath(), '/') === 'foo') {
            // Let's render a drupal page
            return $this->arrayRenderCaller->getResponse(array(
                '#type' => 'markup',
                '#title' => "My title",
                '#markup' => t('Hello world')
            ));
        } else {
            return $delegate->process($request);
        }
    }
}
```

How it works
------------

[](#how-it-works)

This module listens to the `KernelEvents::REQUEST` event that is triggered at each request by the Drupal kernel.

The Symfony request is converted into a PSR-7 request and then is sent to Stratigility's middleware pipe.

If a middleware returns a PSR-7 response, this response is sent back to the user. If all middleware are calling the "next" middleware, the final middleware is a dummy middleware that returns a "418 I'm a teapot" response. This response is interpreted by the module as a "I don't care" response, and the rendering is passed to Drupal that will continue its rendering.

Limitations
-----------

[](#limitations)

Stratigility middlewares provided are not "really" middlewares as they cannot modify the request or the response from Drupal. They run "before" Drupal, in a separate middleware stack. This is still very useful if you want to add your own router in front of Drupal!

Currently, the PSR-7 request is never converted back to a Symfony request. This means that any modification done on the PSR-7 request by a middleware will be ignored by Drupal. Due to the way Drupal is built, it is also impossible to catch the Drupal response in a PSR-15 middleware to modify it.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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 ~268 days

Total

3

Last Release

2907d ago

Major Versions

0.4.x-dev → 1.0.x-dev2018-05-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

![](https://avatars.githubusercontent.com/u/1847918?v=4)[TheCodingMachine](/maintainers/thecodingmachine)[@thecodingmachine](https://github.com/thecodingmachine)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (9 commits)")[![drobieux-julien](https://avatars.githubusercontent.com/u/26894758?v=4)](https://github.com/drobieux-julien "drobieux-julien (1 commits)")

### Embed Badge

![Health badge](/badges/thecodingmachine-drupal-stratigility-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/thecodingmachine-drupal-stratigility-bridge/health.svg)](https://phpackages.com/packages/thecodingmachine-drupal-stratigility-bridge)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[cakephp/authentication

Authentication plugin for CakePHP

1153.6M67](/packages/cakephp-authentication)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[cakephp/authorization

Authorization abstraction layer plugin for CakePHP

742.2M34](/packages/cakephp-authorization)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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