PHPackages                             decodelabs/compass - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. decodelabs/compass

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

decodelabs/compass
==================

Parse, inspect and test IP addresses

v0.4.4(7mo ago)14.2k4MITPHPPHP ^8.4CI passing

Since Sep 9Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/compass)[ Packagist](https://packagist.org/packages/decodelabs/compass)[ RSS](/packages/decodelabs-compass/feed)WikiDiscussions develop Synced 1w ago

READMEChangelog (10)Dependencies (6)Versions (18)Used By (4)

Compass
=======

[](#compass)

[![PHP from Packagist](https://camo.githubusercontent.com/d610fd490e53b1a6f97ebe6c7b86777f1d790acf2280e8c7c401354966256448/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f636f6d706173733f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/compass)[![Latest Version](https://camo.githubusercontent.com/1bf19da1a47d02e7a10aaddb9ad4acc0c25db4574ea75b1bd40c7adf010cd0c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f636f6d706173732e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/compass)[![Total Downloads](https://camo.githubusercontent.com/60217bf9b0b8900e77a7be384b9b3ccf6d979f9106ad3f5a7d91451f3608ece9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f636f6d706173732e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/compass)[![GitHub Workflow Status](https://camo.githubusercontent.com/b2ff1a09cc25d4d5cc2511e3d2c49de461d68e1fa98114a6428e68136ab5082d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f636f6d706173732f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/compass/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/814994b2151b5acf7bf99fefd6a1dee7b7a3f3dea5d4f99b70114fd670bdb3ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f636f6d706173733f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/compass)

### Parse, inspect and test IP addresses

[](#parse-inspect-and-test-ip-addresses)

Compass provides an accurate disassembly of both v4 and v6 IP addresses and the means to inspect and compare them.

---

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

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/compass
```

Usage
-----

[](#usage)

Parse IP strings, integers and binaries and inspect them:

```
use DecodeLabs\Compass\Ip;

$ip = Ip::parse('127.0.0.1');

if($ip->isV4()) {
    // Do something
}

if($ip->isLoopback()) {
    // Do something else
}

$v6Hybrid = $ip->toV6(); // ::ffff:127.0.0.1

$v6 = Ip::parse('fe80:0:0:0:202:b3ff:fe1e:8329');

if($ip->isV6()) {
    // The future
}
```

Check to see if an IP is within a range:

```
if($ip->isIn('127.0.0.0/8')) {} // CIDR
if($ip->isIn('127.0.0.0/255.0.0.0')) {} // Netmask
if($ip->isIn('127.0.0.4-127.0.0.10')) {} // Range
if($ip->isIn('127.0.0.4+6')) {} // Relative range
if($ip->isIn('127.0.0.*')) {} // Wildcards

if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:0/128')) {} // CIDR
if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:0-fe80:0:0:0:202:b3ff:fe1e:ffff')) {} // Range
if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:0+9999')) {} // Relative range
if($v6->isIn('fe80:0:0:0:202:b3ff:fe1e:*')) {} // Wildcards
```

Licensing
---------

[](#licensing)

Compass is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance67

Regular maintenance activity

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~74 days

Recently: every ~10 days

Total

16

Last Release

227d ago

PHP version history (3 changes)v0.1.0PHP ^8.0

v0.1.6PHP ^8.1

v0.3.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (88 commits)")

---

Tags

ipipv4ipv6phpaddressIP

### Embed Badge

![Health badge](/badges/decodelabs-compass/health.svg)

```
[![Health](https://phpackages.com/badges/decodelabs-compass/health.svg)](https://phpackages.com/packages/decodelabs-compass)
```

###  Alternatives

[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3126.4M44](/packages/mlocati-ip-lib)[markrogoyski/ipv4-subnet-calculator

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

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[mantoufan/yzhanip

Crawl, match, parse IP or IP range, check if IP or range is in another range. Support IPv4, IPv6, IP Interval, Wildcard and CIDR. Check if IP is Cloudflare node IP, Google bot IP. 爬取，正则匹配，解析 IP 和 IP 范围，检测 IP 或范围是否在另一个范围中。支持 IPv4，IPv6，区间、通配符或 CIDR 表示的 IP 范围。检测 IP 是否是 Cloudflare 节点或 Google 漫游器 IP

541.4k](/packages/mantoufan-yzhanip)[davidepastore/slim-restrict-route

A Slim middleware to restrict ip addresses that will access to your routes

2220.6k1](/packages/davidepastore-slim-restrict-route)

PHPackages © 2026

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