PHPackages                             athlon1600/php-cidr-range-optimizer - 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. athlon1600/php-cidr-range-optimizer

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

athlon1600/php-cidr-range-optimizer
===================================

Given a list of IP ranges, merge them into the smallest possible list of CIDRs.

v1.0.2(1y ago)5723MITPHPPHP &gt;=7.4.0

Since Jul 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Athlon1600/php-cidr-range-optimizer)[ Packagist](https://packagist.org/packages/athlon1600/php-cidr-range-optimizer)[ RSS](/packages/athlon1600-php-cidr-range-optimizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Optimize CIDR Ranges
--------------------

[](#optimize-cidr-ranges)

[![Minimum PHP Version](https://camo.githubusercontent.com/c784730f9ed280b47efe2b13c6395f03b1d9e95e4e77396824472a37e6a6665b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253230253345253344372e342d626c75652e737667)](https://php.net/)[![GitHub Workflow Status (with event)](https://camo.githubusercontent.com/a16cd96fca14eed5359295ed0b1743cd69708c3c59272fc1bea4a294f015bd07/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4174686c6f6e313630302f7068702d636964722d72616e67652d6f7074696d697a65722f63692e796d6c)](https://camo.githubusercontent.com/a16cd96fca14eed5359295ed0b1743cd69708c3c59272fc1bea4a294f015bd07/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4174686c6f6e313630302f7068702d636964722d72616e67652d6f7074696d697a65722f63692e796d6c)

Given a list of IP address ranges, minify that list to the smallest possible size by performing the following optimizations:

- removing invalid IP addresses/ranges from the list
- removing duplicates
- removing IP ranges already covered by larger ranges in the list
- merging adjacent IP ranges into larger, contiguous blocks

⭐ Demo
------

[](#star-demo)

An online tool that uses a near exact version of this library:

-

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

[](#installation)

```
composer require athlon1600/php-cidr-range-optimizer
```

Usage
-----

[](#usage)

Build your list of IP ranges into `CIDRList` object, then use `RangeOptimizer` class to optimize it. Example:

```
use ProxyNova\RangeOptimizer\CIDRList;
use ProxyNova\RangeOptimizer\RangeOptimizer;

$ranges = CIDRList::fromArray([
    "192.168.1.0/26",
    "192.168.1.64/27",
    "192.168.1.96/27",
    "10.1.0.0/26",
    "10.1.0.64/26"
]);

// returns new optimized CIDRList object
$optimized = RangeOptimizer::optimize($ranges);

echo $optimized;
```

Output:

```
10.1.0.0/25
192.168.1.0/25

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

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

Every ~16 days

Total

3

Last Release

633d ago

### Community

Maintainers

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

---

Top Contributors

[![Athlon1600](https://avatars.githubusercontent.com/u/1063088?v=4)](https://github.com/Athlon1600 "Athlon1600 (14 commits)")

---

Tags

aggregatecidrcidr-rangeip-rangecidrip rangescidr optimizersubnet optimizernetwork range optimizercidr merge

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/athlon1600-php-cidr-range-optimizer/health.svg)

```
[![Health](https://phpackages.com/badges/athlon1600-php-cidr-range-optimizer/health.svg)](https://phpackages.com/packages/athlon1600-php-cidr-range-optimizer)
```

###  Alternatives

[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.2M24](/packages/s1lentium-iptools)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

45778.7k4](/packages/jalle19-php-whitelist-check)[tholu/php-cidr-match

CIDRmatch is a library to match an IP to an IP range in CIDR notation (IPv4 and IPv6).

37211.1k](/packages/tholu-php-cidr-match)[jaaulde/php-ipv4

PHP classes for working with IPV4 addresses and networks.

1034.6k](/packages/jaaulde-php-ipv4)

PHPackages © 2026

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