PHPackages                             chialab/ip - 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. chialab/ip

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

chialab/ip
==========

Minimal library to manage IP addresses, subnets, netmasks, etc.

v1.0.0(3y ago)418.3k↓33.3%[4 PRs](https://github.com/chialab/php-ip/pulls)1MITPHPPHP &gt;= 7.4

Since Nov 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/chialab/php-ip)[ Packagist](https://packagist.org/packages/chialab/ip)[ RSS](/packages/chialab-ip/feed)WikiDiscussions main Synced 1mo ago

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

IP Address library for PHP
==========================

[](#ip-address-library-for-php)

[![Run tests](https://github.com/chialab/php-ip/actions/workflows/test.yml/badge.svg)](https://github.com/chialab/php-ip/actions/workflows/test.yml)[![codecov](https://camo.githubusercontent.com/cf851cf3699f583aae978b660c17829f98345a4abe6653b3c15859498a8893d1/68747470733a2f2f636f6465636f762e696f2f67682f636869616c61622f7068702d69702f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d54334c54475859474f4a)](https://codecov.io/gh/chialab/php-ip)

This library for PHP 7.4+ builds an abstraction over management of Internet Protocol versions, addresses and CIDR blocks.

Using this library makes it easy to check if an IP address belongs to a subnet or not.

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

[](#installation)

Installing this library can be done via Composer:

```
$ composer require chialab/ip
```

Usage
-----

[](#usage)

```
use Chialab\Ip;

$address = Ip\Address::parse('192.168.1.1');
var_dump($address->getProtocolVersion() === Ip\ProtocolVersion::ipv4()); // bool(true)
var_dump($address->getProtocolVersion() === Ip\ProtocolVersion::ipv6()); // bool(false)

$subnet = Ip\Subnet::parse('fec0::1/16');
var_dump((string)$subnet->getFirstAddress()); // string(6): "fec0::"
var_dump((string)$subnet->getNetmask()); // string(6) "ffff::"
var_dump($subnet->contains($address)); // bool(false)
var_dump($subnet->contains(Ip\Address::parse('fec0:fe08:0123:4567:89ab:cdef:1234:5678'))); // bool(true)
var_dump($subnet->hasSubnet(Ip\Subnet::parse('fec0:fe08::/32'))); // bool(true)
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

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

1274d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00305fda0159b5d71f7bd6848ae7d3f7ac27d0179d79d58c4847848c8bd673e0?d=identicon)[fquffio](/maintainers/fquffio)

![](https://www.gravatar.com/avatar/36a1b89a62185411675b209cd97652abd29a4e98bd3e68cb5e402bee9ae883d6?d=identicon)[le0m](/maintainers/le0m)

![](https://www.gravatar.com/avatar/4bb153a6227d7c6cd124f94c414e63d68cb1b1def8a6fdac75770c495cb8713d?d=identicon)[edoardocavazza](/maintainers/edoardocavazza)

---

Top Contributors

[![fquffio](https://avatars.githubusercontent.com/u/7108146?v=4)](https://github.com/fquffio "fquffio (15 commits)")

---

Tags

cidr-notationinternet-protocolip-addressphpphp7php8

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chialab-ip/health.svg)

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

###  Alternatives

[dhtmlx/connector-php

PHP extension for the DHTMLX library

2665.3k2](/packages/dhtmlx-connector-php)

PHPackages © 2026

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