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

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

componenta/ip-address
=====================

IP address value object

v1.0.0(1mo ago)00MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Componenta IP Address
=====================

[](#componenta-ip-address)

IPv4/IPv6 value object with validation, normalization, classification, CIDR checks, masking, binary conversion, and JSON/string serialization.

Use it for request metadata, access rules, audit logs, and infrastructure code that should not pass raw IP strings around.

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

[](#installation)

```
composer require componenta/ip-address
```

Related Packages
----------------

[](#related-packages)

This package validates IP addresses without neighboring Componenta packages.

PackageWhy it may be used nearby`componenta/http-trusted-proxy-middleware`Trusted proxy middleware can expose client IP values on the request.`componenta/policy`Authorization policies can use IP/CIDR checks as context.`componenta/validation`Can validate raw user input before creating `IpAddress`.Usage
-----

[](#usage)

```
use Componenta\Stdlib\IpAddress;

$ip = IpAddress::fromString('192.168.1.10');

(string) $ip;              // "192.168.1.10"
$ip->version->name;        // "V4"
$ip->isPrivate();          // true
$ip->isPublic();           // false
$ip->isInRange('192.168.1.0/24'); // true
$ip->masked();             // "192.168.1.***"
```

Constructors And Validation
---------------------------

[](#constructors-and-validation)

- `fromString()` validates and normalizes or throws `InvalidArgumentException`
- `tryFromString()` returns `null` for invalid input
- `isValid()`, `isValidV4()`, and `isValidV6()` perform static checks

Normalization uses `inet_pton()`/`inet_ntop()`.

Classification
--------------

[](#classification)

The object can detect:

- IPv4 vs IPv6
- RFC 1918/private ranges and IPv6 unique local range
- loopback
- link-local
- multicast
- public routability

`isPublic()` is not the inverse of `isPrivate()`. Reserved, documentation, loopback, multicast, and link-local ranges may be neither public nor private.

CIDR And Conversion
-------------------

[](#cidr-and-conversion)

`isInRange()` returns `false` for invalid CIDR input, invalid prefix, or IP version mismatch.

`toBinary()` returns packed binary form. `toLong()` returns a numeric string and requires the GMP extension for IPv6-safe conversion.

Equality
--------

[](#equality)

- `equals()` compares normalized values and does not treat IPv4 and IPv4-mapped IPv6 as equal
- `equalsCanonical()` maps IPv4 to IPv6 first and can compare across versions

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

43d ago

### Community

Maintainers

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

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[norkunas/youtube-dl-php

youtube-dl / yt-dlp wrapper for php

514356.8k18](/packages/norkunas-youtube-dl-php)[theodo-evolution/legacy-wrapper-bundle

40124.9k](/packages/theodo-evolution-legacy-wrapper-bundle)

PHPackages © 2026

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