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)2582.1M↓39.6%20[2 issues](https://github.com/darsyn/ip/issues)16MITPHPCI passing

Since Aug 22Pushed 3w ago8 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 2d ago

READMEChangelog (2)Dependencies (3)Versions (30)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 all supported PHP versions.

> 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 (currently confirmed up to `8.5`), 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 `7.4` and `8.5`, 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).

```
