PHPackages                             northwoods/conditional-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. northwoods/conditional-middleware

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

northwoods/conditional-middleware
=================================

Middleware proxy for request condition checks

1.0.0(7y ago)32.5k↓36.4%1MITPHPPHP ^7.1

Since Oct 17Pushed 7y ago2 watchersCompare

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

READMEChangelogDependencies (6)Versions (2)Used By (0)

Northwoods Conditional Middleware
=================================

[](#northwoods-conditional-middleware)

[![Build Status](https://camo.githubusercontent.com/2c1ec2e5029e6d24565561286745f04331601713cfce4b5e39d36ddd8025383b/68747470733a2f2f7472617669732d63692e636f6d2f6e6f727468776f6f64732f636f6e646974696f6e616c2d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/northwoods/conditional-middleware)[![Code Quality](https://camo.githubusercontent.com/000be65ed9963a967e5e22589b5b80404e26c468516d7db34d12fcc930be7c2e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e6f727468776f6f64732f636f6e646974696f6e616c2d6d6964646c65776172652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/northwoods/conditional-middleware/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cc395216b21b63713d6c8993c715c1ec12a8e20b35ba4516fa786d3afcb62897/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e6f727468776f6f64732f636f6e646974696f6e616c2d6d6964646c65776172652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/northwoods/conditional-middleware/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/4e6e8e01af6a264a860d0ee3d345b889334cc401879326402c022db8a315c4b8/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f727468776f6f64732f636f6e646974696f6e616c2d6d6964646c65776172652e7376673f7374796c653d666c6174)](https://packagist.org/packages/northwoods/conditional-middleware)[![Total Downloads](https://camo.githubusercontent.com/2a36026641fd55a4abfe0326c52103e9ae4d44c0d902024aeb6853b67064e9f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6f727468776f6f64732f636f6e646974696f6e616c2d6d6964646c65776172652e7376673f7374796c653d666c6174)](https://packagist.org/packages/northwoods/conditional-middleware)[![License](https://camo.githubusercontent.com/328cac9d5f9318f81d0342240e4e9c2443468202cca021e99bd50cfe524edeec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f727468776f6f64732f636f6e646974696f6e616c2d6d6964646c65776172652e7376673f7374796c653d666c6174)](https://packagist.org/packages/northwoods/conditional-middleware)

Middleware proxy that executes a middleware based on request conditions.

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

[](#installation)

The best way to install and use this package is with [composer](http://getcomposer.org/):

```
composer require northwoods/conditional-middleware
```

Usage
-----

[](#usage)

```
use Northwoods\Middleware\ConditionalMiddleware;

/** @var \Psr\Http\Server\MiddlewareInterface */
$actual = /* any existing middleware */

$middleware = new ConditionalMiddleware($actual, function (Request $request): bool {
    return $request->getHeaderLine('accept') === 'application/json';
});
```

In this example, the wrapped `$actual` middleware will only be executed if the request accepts the `application/json` content type.

### Condition Callable

[](#condition-callable)

The condition callable should use the following signature:

```
function (Request $request): bool;
```

The condition must return `true` (by strict `===` comparison) for the wrapped middleware to be executed. If the condition check fails the handler will be called immediately.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

2806d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38203?v=4)[Woody Gilk](/maintainers/shadowhand)[@shadowhand](https://github.com/shadowhand)

---

Top Contributors

[![shadowhand](https://avatars.githubusercontent.com/u/38203?v=4)](https://github.com/shadowhand "shadowhand (2 commits)")

---

Tags

conditionalmiddlewareproxypsr-15httprequestmiddlewareproxywrapperpsr-15conditionsconditional

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/northwoods-conditional-middleware/health.svg)

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

###  Alternatives

[psr/http-server-middleware

Common interface for HTTP server-side middleware

18399.3M1.8k](/packages/psr-http-server-middleware)[mezzio/mezzio

PSR-15 Middleware Microframework

3903.8M120](/packages/mezzio-mezzio)[middlewares/request-handler

Middleware to execute request handlers

451.7M28](/packages/middlewares-request-handler)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

577.0M95](/packages/laminas-laminas-stratigility)[middlewares/utils

Common utils for PSR-15 middleware packages

503.6M94](/packages/middlewares-utils)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

131.7M39](/packages/mezzio-mezzio-authentication)

PHPackages © 2026

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