PHPackages                             blackcube/yii-proxy-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. blackcube/yii-proxy-middleware

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

blackcube/yii-proxy-middleware
==============================

Yiisoft TrustedHostsNetworkResolver fork with CIDR support in withTrustedIps()

1.0.0(1mo ago)00BSD-3-ClausePHPPHP ^8.1

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/blackcubeio/yii-proxy-middleware)[ Packagist](https://packagist.org/packages/blackcube/yii-proxy-middleware)[ Docs](https://github.com/blackcubeio/yii-proxy-middleware)[ RSS](/packages/blackcube-yii-proxy-middleware/feed)WikiDiscussions main Synced 1mo ago

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

Blackcube Yii Proxy Middleware
==============================

[](#blackcube-yii-proxy-middleware)

Fork of [`Yiisoft\ProxyMiddleware\TrustedHostsNetworkResolver`](https://github.com/yiisoft/proxy-middleware) with CIDR range support added to `withTrustedIps()`.

[![License](https://camo.githubusercontent.com/6cb285b57819f8de0acfb34923298f4f569f962544e8fe35331da2d163f4e485/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d626c75652e737667)](LICENSE.md)[![Packagist Version](https://camo.githubusercontent.com/868227b77aec981fc49f7077693690eaf46823d57b73a169ffdd46dcbac386da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c61636b637562652f7969692d70726f78792d6d6964646c65776172652e737667)](https://packagist.org/packages/blackcube/yii-proxy-middleware)

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

[](#installation)

```
composer require blackcube/yii-proxy-middleware
```

Why this fork?
--------------

[](#why-this-fork)

The upstream `TrustedHostsNetworkResolver::withTrustedIps()` rejects any entry that is not a plain IP — **even though its own matching engine (`Yiisoft\NetworkUtilities\IpRanges`) already supports CIDR**.

EntryUpstreamThis fork`192.168.1.1`acceptedaccepted`10.0.0.0/8`rejectedaccepted`2001:db8::/32`rejectedaccepted`10.0.0.0/33`rejectedrejected`not-an-ip`rejectedrejectedEvery internal state field in the upstream class is `private`, so clean extension is not possible — the class is duplicated and `withTrustedIps()` is the only behavioural change.

Usage
-----

[](#usage)

```
use Blackcube\ProxyMiddleware\TrustedHostsNetworkResolver;

$middleware = (new TrustedHostsNetworkResolver())
    ->withTrustedIps([
        '10.0.0.0/8',          // whole private network
        '192.168.1.0/24',      // LAN subnet
        '2001:db8::/32',       // IPv6 documentation range
        '203.0.113.42',        // single IP still works
    ]);
```

All other methods (`withForwardedHeaderGroups()`, `withTypicalForwardedHeaders()`, `withConnectionChainItemsAttribute()`, `process()`) behave identically to the upstream — see the [upstream docs](https://github.com/yiisoft/proxy-middleware) for details.

Validation rules
----------------

[](#validation-rules)

`withTrustedIps()` throws `InvalidArgumentException` when:

- an entry is not a non-empty string
- an entry contains `/` but is not a valid CIDR (invalid prefix, malformed IP)
- an entry has no `/` and is not a valid IPv4/IPv6 address

Credits
-------

[](#credits)

Forked from [`yiisoft/proxy-middleware`](https://github.com/yiisoft/proxy-middleware) (© Yii Software, BSD 3-Clause). All credit for the original `TrustedHostsNetworkResolver` goes to the Yiisoft contributors.

License
-------

[](#license)

BSD 3-Clause — see [LICENSE.md](LICENSE.md) for the full license text, including the upstream copyright notice.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

46d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

middlewareproxypsr-15yiicidrtrusted-hosts

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/blackcube-yii-proxy-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/blackcube-yii-proxy-middleware/health.svg)](https://phpackages.com/packages/blackcube-yii-proxy-middleware)
```

###  Alternatives

[fideloper/proxy

Set trusted proxies for Laravel

7.3k174.4M559](/packages/fideloper-proxy)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k378.1M441](/packages/symfony-var-exporter)[friendsofphp/proxy-manager-lts

Adding support for a wider range of PHP versions to ocramius/proxy-manager

1.2k139.1M104](/packages/friendsofphp-proxy-manager-lts)[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[yiisoft/rate-limiter

Yii Rate Limiter Middleware

2965.5k](/packages/yiisoft-rate-limiter)[romka-chev/yii2-swiper

Yii2 extension for Swiper slider

1840.6k](/packages/romka-chev-yii2-swiper)

PHPackages © 2026

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