PHPackages                             mesour/ip-addresses - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mesour/ip-addresses

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mesour/ip-addresses
===================

IP address normalizer and validator. For IPv4 and IPv6.

v0.3.0(3y ago)1329.6k↑21.3%21MITPHPPHP &gt;=8.0CI passing

Since Feb 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mesour/ip-addresses)[ Packagist](https://packagist.org/packages/mesour/ip-addresses)[ GitHub Sponsors](https://github.com/mesour)[ RSS](/packages/mesour-ip-addresses/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (1)

Mesour IP addresses
===================

[](#mesour-ip-addresses)

- [Author](http://mesour.com)
- IP address normalizer and validator. For IPv4 and IPv6.

Install
=======

[](#install)

- With [Composer](https://getcomposer.org)

    ```
      composer require mesour/ip-addresses

    ```
- Or download source from [GitHub](https://github.com/mesour/ip-addresses/releases)

Usage
=====

[](#usage)

### Usage: `Mesour\IpAddresses\IpAddressValidator`

[](#usage-mesouripaddressesipaddressvalidator)

```
Assert::true(IpAddressValidator::isIpV6('2a00:5565:2222:800::200e'));

Assert::true(IpAddressValidator::isIpV4('127.0.0.1'));
```

### Usage: `Mesour\IpAddresses\IpAddressNormalizer`

[](#usage-mesouripaddressesipaddressnormalizer)

Normalize IPv6:

```
IpAddressNormalizer::normalizeIpV6('2001:db8:800::ff00:42:8329');

// result is: 2001:0db8:0800:0000:0000:ff00:0042:8329
```

Compress IPv6:

```
IpAddressNormalizer::compressIpV6('2001:0db8:0800:0000:0000:ff00:0042:8329');

// result is: 2001:db8:800::ff00:42:8329
```

### Usage: `Mesour\IpAddresses\IpAddress`

[](#usage-mesouripaddressesipaddress)

Normalize IPv4:

```
$ipAddress = IpAddress::create('127.0.0.1');

$ipAddress->isIpV4(); // result is: true
$ipAddress->isIpV6(); // result is: false
$ipAddress->getValue(); // result is: 127.0.0.1
```

Normalize IPv6:

- Result of `getValue` is compressed IPv6 value

```
$ipAddress = IpAddress::create('2001:0db8:0800:0000:0000:ff00:0042:8329');

$ipAddress->isIpV4(); // result is: false
$ipAddress->isIpV6(); // result is: true
$ipAddress->getValue(); // result is: 2001:db8:800::ff00:42:8329
```

Development
===========

[](#development)

- Syntax check: `vendor/bin/parallel-lint src tests`
- PHP Stan: `vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests`
- Run tests: `vendor/bin/tester -p php tests/ -s -c tests/php.ini`

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

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

Total

3

Last Release

1346d ago

PHP version history (3 changes)v0.1.0PHP &gt;=7.0

v0.2.0PHP &gt;=7.1

v0.3.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a73dd796d901629d3063ead8ab7e11cf2bd80c5c691feacd029354b01b068d88?d=identicon)[mesour](/maintainers/mesour)

---

Top Contributors

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

---

Tags

ipipaddressipv4ipv6normalizationvalidatornormalizervalidatorip-address

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

6.0k39.9M415](/packages/respect-validation)[seld/jsonlint

JSON Linter

1.3k228.7M271](/packages/seld-jsonlint)[composer/spdx-licenses

SPDX licenses list and validation library.

1.4k193.5M40](/packages/composer-spdx-licenses)[opis/json-schema

Json Schema Validator for PHP

65243.6M302](/packages/opis-json-schema)[laminas/laminas-validator

Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria

15848.2M222](/packages/laminas-laminas-validator)[ergebnis/json-schema-validator

Provides a JSON schema validator, building on top of justinrainbow/json-schema.

3630.9M7](/packages/ergebnis-json-schema-validator)

PHPackages © 2026

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