PHPackages                             darsyn/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. [Database &amp; ORM](/categories/database)
4. /
5. darsyn/ip

ActiveLibrary[Database &amp; ORM](/categories/database)

darsyn/ip
=========

An immutable IP Address value object that provides several different notations, including helper functions.

6.0.0(1y ago)2572.0M—4.3%20[2 issues](https://github.com/darsyn/ip/issues)16MITPHPCI passing

Since Aug 22Pushed 1y ago9 watchersCompare

[ Source](https://github.com/darsyn/ip)[ Packagist](https://packagist.org/packages/darsyn/ip)[ Docs](https://github.com/darsyn/ip)[ RSS](/packages/darsyn-ip/feed)WikiDiscussions 6.x Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (27)Used By (16)

IP is an immutable value object for (both version 4 and 6) IP addresses. Several helper methods are provided for ranges, broadcast and network addresses, subnet masks, whether an IP is a certain type (defined by RFC's), etc.

This project aims for simplicity of use and any contribution towards that goal - whether a bug report, modifications to the codebase, or an improvement to the accuracy or readability of the documentation - are always welcome.

Documentation
=============

[](#documentation)

Full documentation is available in the [`docs/`](docs/) folder.

Compatibility
-------------

[](#compatibility)

This library has extensive test coverage using PHPUnit on PHP versions: `7.1`, `7.2`, `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3` and `8.4`.

> Versions `5.x.x` of this library are compatible with PHP versions `5.6` to `8.3` (and will continue to receive bug fixes).
>
> Versions `6.x.x` of this library are compatible with PHP versions `7.1` and above, and will receive continued support for future versions of PHP (also accepting proposed new features).

Static analysis is performed with PHPStan at `max` level on PHP `8.4`, using core, bleeding edge, and deprecation rules.

> The Doctrine features for this library have been split off into their own package, [`darsyn/ip-doctrine`](https://packagist.org/packages/darsyn/ip-doctrine).

Brief Example
-------------

[](#brief-example)

- There are three main classes: [`IPv4`](src/Version/IPv4.php), [`IPv6`](src/Version/IPv6.php), and [`Multi`](src/Version/Multi.php) (for both version 4 and 6 addresses).
- Objects are created using a static factory method [`IpInterface::factory()`](src/IpInterface.php) instead of the constructor to speed up internal processes.
- When using `Multi`, the default strategy for representing version 4 addresses internally is [IPv4-mapped](docs/05-strategies.md).

```
