PHPackages                             jasny/dummy-middleware - 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. jasny/dummy-middleware

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

jasny/dummy-middleware
======================

Dummy client and server middleware for PSR-7 requests

v1.0.0(7y ago)013MITPHPPHP &gt;=7.2.0

Since Mar 13Pushed 6y agoCompare

[ Source](https://github.com/jasny/dummy-middleware)[ Packagist](https://packagist.org/packages/jasny/dummy-middleware)[ RSS](/packages/jasny-dummy-middleware/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Jasny Dummy Middleware
======================

[](#jasny-dummy-middleware)

[![Build Status](https://camo.githubusercontent.com/31d443779e61c731c532cb2b49647a7af5b1b5727e8fefc0462b1f88a55a0801/68747470733a2f2f7472617669732d63692e6f72672f6a61736e792f64756d6d792d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jasny/dummy-middleware)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/952cbe47a7d0c162e1e880627d14d06f6631d7cd30e38e605d5d402b7be16c1d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f64756d6d792d6d6964646c65776172652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/dummy-middleware/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/6e29fc3070e527812e03b17ef394337477c6f768e1f746b627e72288fb657623/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f64756d6d792d6d6964646c65776172652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/dummy-middleware/?branch=master)[![Packagist Stable Version](https://camo.githubusercontent.com/a8725b088d086ed816992a87a23abd91e4ff7ef519400de104ce5b23d04eb24c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736e792f64756d6d792d6d6964646c65776172652e737667)](https://packagist.org/packages/jasny/dummy-middleware)[![Packagist License](https://camo.githubusercontent.com/a03d666471ea55c869e526760fe3cc1edd0432caed5ad6faf868b3c2347a57d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a61736e792f64756d6d792d6d6964646c65776172652e737667)](https://packagist.org/packages/jasny/dummy-middleware)

Dummy client and server middleware for PSR-7 requests. Works both as PSR-15 and double pass middleware.

The dummy services work as [null objects](https://sourcemaking.com/design_patterns/null_object) / passthrough, preventing the use of if's.

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

[](#installation)

```
composer require jasny/dummy-middleware

```

Usage
-----

[](#usage)

### Server middleware

[](#server-middleware)

Server middleware can be used all passthrough of PSR-7 server requests.

#### Single pass middleware (PSR-15)

[](#single-pass-middleware-psr-15)

The middleware implements the PSR-15 `MiddlewareInterface`. As PSR standard many new libraries support this type of middleware, for example [Zend Stratigility](https://docs.zendframework.com/zend-stratigility/).

```
use Jasny\Dummy\ServerMiddleware;
use Zend\Stratigility\MiddlewarePipe;
use Zend\Diactoros\ResponseFactory;

$middleware = new ServerMiddleware();

$app = new MiddlewarePipe();
$app->pipe($middleware);
```

#### Double pass middleware

[](#double-pass-middleware)

Many PHP libraries support double pass middleware. These are callables with the following signature;

```
fn(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
```

To get a callback to be used by libraries as [Jasny Router](https://github.com/jasny/router) and [Relay](http://relayphp.com/), use the `asDoublePass()` method.

```
use Jasny\Dummy\ServerMiddleware;
use Relay\RelayBuilder;

$middleware = new ServerMiddleware();

$relayBuilder = new RelayBuilder($resolver);
$relay = $relayBuilder->newInstance([
    $middleware->asDoublePass(),
]);

$response = $relay($request, $baseResponse);
```

### Client middleware

[](#client-middleware)

Client middleware can be used for PSR-7 compatible HTTP clients like [Guzzle](http://docs.guzzlephp.org) and [HTTPlug](http://docs.php-http.org).

#### Double pass middleware

[](#double-pass-middleware-1)

The client middleware can be used by any client that does support double pass middleware. Such middleware are callables with the following signature;

```
fn(RequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface
```

Most HTTP clients do not support double pass middleware, but a type of single pass instead. However more general purpose PSR-7 middleware libraries, like [Relay](http://relayphp.com/), do support double pass.

```
use Relay\RelayBuilder;
use Jasny\Dummy\ClientMiddleware;

$middleware = new ClientMiddleware();

$relayBuilder = new RelayBuilder($resolver);
$relay = $relayBuilder->newInstance([
    $middleware->asDoublePass(),
]);

$response = $relay($request, $baseResponse);
```

*The client middleware does not conform to PSR-15 (single pass) as that is intended for server requests only.*

#### Guzzle

[](#guzzle)

[Guzzle](http://docs.guzzlephp.org) is the most popular HTTP Client for PHP. The middleware has a `forGuzzle()` method that creates a callback which can be used as Guzzle middleware.

```
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Client;
use Jasny\Dummy\ClientMiddleware;

$middleware = new ClientMiddleware();

$stack = new HandlerStack();
$stack->push($middleware->forGuzzle());

$client = new Client(['handler' => $stack]);
```

#### HTTPlug

[](#httplug)

[HTTPlug](http://docs.php-http.org/en/latest/httplug/introduction.html) is the HTTP client of PHP-HTTP. It allows you to write reusable libraries and applications that need an HTTP client without binding to a specific implementation.

The `forHttplug()` method for the middleware creates an object that can be used as HTTPlug plugin.

```
use Http\Discovery\HttpClientDiscovery;
use Http\Client\Common\PluginClient;
use Jasny\Dummy\ClientMiddleware;

$middleware = new ClientMiddleware();

$pluginClient = new PluginClient(
    HttpClientDiscovery::find(),
    [
        $middleware->forHttplug(),
    ]
);
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

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

Unknown

Total

1

Last Release

2620d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3379a93d51305df325df9045e1a8b205d195e4e8c01312dff53a000ee79002eb?d=identicon)[jasny](/maintainers/jasny)

---

Top Contributors

[![jasny](https://avatars.githubusercontent.com/u/100821?v=4)](https://github.com/jasny "jasny (5 commits)")

---

Tags

dummymiddlewarenull-object-patternphp7psr-15psr-7

### Embed Badge

![Health badge](/badges/jasny-dummy-middleware/health.svg)

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

###  Alternatives

[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

538204.9M23](/packages/league-uri-interfaces)[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28483.0k2](/packages/mezzio-mezzio-authentication-oauth2)[openswoole/core

Openswoole core library

181.1M32](/packages/openswoole-core)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[jimtools/jwt-auth

PSR-15 JWT Authentication middleware, A replacement for tuupola/slim-jwt-auth

20142.3k3](/packages/jimtools-jwt-auth)

PHPackages © 2026

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