2017 © Pedro Peláez
 

library ip

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

image

darsyn/ip

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

  • Friday, June 22, 2018
  • by zanderbaldwin
  • Repository
  • 6 Watchers
  • 63 Stars
  • 86,952 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 6 Forks
  • 3 Open issues
  • 25 Versions
  • 21 % Grown

The README.md

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., (*1)

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., (*2)

Documentation

Full documentation is available in the docs/ folder., (*3)

Compatibility

This library has extensive test coverage using PHPUnit on PHP versions: 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, and 8.3., (*4)

Static analysis is performed with PHPStan at max level on PHP 8.3, using core, bleeding edge, and deprecation rules., (*5)

The Doctrine features for this library have been split off into their own package, darsyn/ip-doctrine., (*6)

Brief Example

  • There are three main classes: IPv4, IPv6, and Multi (for both version 4 and 6 addresses).
  • Objects are created using a static factory method IpInterface::factory() instead of the constructor to speed up internal processes.
  • When using Multi, the default strategy for representing version 4 addresses internally is IPv4-mapped.
<?php declare(strict_types=1);

use Darsyn\IP\Exception;
use Darsyn\IP\Version\IPv4;

try {
    $ip = IPv4::factory('192.168.0.1');
} catch (Exception\InvalidIpAddressException $e) {
    exit('The IP address supplied is invalid!');
}

$companyNetwork = IPv4::factory('216.58.198.174');
if (!$ip->inRange($companyNetwork, 25)) {
    throw new \Exception('Request not from a known company IP address.');
}

// Is it coming from the local network?
if (!$ip->isPrivateUse()) {
    record_visit($ip->getBinary(), $_SERVER['HTTP_USER_AGENT']);
}

Code of Conduct

This project includes and adheres to the Contributor Covenant as a Code of Conduct., (*7)

License

Please see the separate license file included in this repository for a full copy of the MIT license, which this project is licensed under., (*8)

Authors

If you make a contribution (submit a pull request), don't forget to add your name here!, (*9)

The Versions

22/06 2018

dev-develop

dev-develop https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php-ipv6 >=5.6
  • php-64bit >=5.6

 

library ip immutable ipv6 ipv4 value-object

15/06 2018

dev-master

9999999-dev https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php-ipv6 >=5.6
  • php-64bit >=5.6

 

library ip immutable ipv6 ipv4 value-object

15/06 2018

4.0.0

4.0.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php-ipv6 >=5.6
  • php-64bit >=5.6

 

library ip immutable ipv6 ipv4 value-object

15/06 2018

3.4.0

3.4.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

library ip immutable ipv6 ipv4 value-object

18/04 2018

dev-feature/deprecate

dev-feature/deprecate https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

library ip immutable ipv6 ipv4 value-object

17/04 2018

4.0.0-beta2

4.0.0.0-beta2 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php-ipv6 >=5.6
  • php-64bit >=5.6

 

library ip immutable ipv6 ipv4 value-object

26/02 2018

4.0.0-beta1

4.0.0.0-beta1 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php-ipv6 >=5.6
  • php-64bit >=5.6

 

library ip immutable ipv6 ipv4 value-object

23/02 2018

dev-feature/serialise

dev-feature/serialise https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

library ip immutable ipv6 ipv4 value-object

16/11 2017

dev-feature/upgrade-php

dev-feature/upgrade-php https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=7.1

 

library ip immutable ipv6 ipv4 value-object

26/10 2017

4.0.0-alpha

4.0.0.0-alpha https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php-ipv6 >=5.6
  • php-64bit >=5.6

 

library ip immutable ipv6 ipv4 value-object

03/08 2017

3.3.1

3.3.1.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

library ip immutable ipv6 ipv4 value-object

07/03 2017

3.3.0

3.3.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

library ip immutable ipv6 ipv4 value-object

06/03 2017

dev-feature/mapped-derived

dev-feature/mapped-derived https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

19/12 2016

3.2.0

3.2.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

18/07 2016

dev-feature/symfony-commands

dev-feature/symfony-commands https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

16/06 2016

3.1.0

3.1.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

02/06 2016

3.0.1

3.0.1.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

02/06 2016

3.0.0

3.0.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

17/05 2016

2.0.2

2.0.2.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

library ip immutable ipv6 ipv4 value-object

17/05 2016

2.0.1

2.0.1.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Development Requires

library ip immutable ipv6 ipv4 value-object

22/08 2015

2.0.0

2.0.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Development Requires

library ip immutable ipv6 ipv4 value-object

22/08 2015

1.1.2

1.1.2.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Development Requires

library ip immutable ipv6 ipv4 value-object

22/08 2015

1.1.1

1.1.1.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Development Requires

library ip immutable ipv6 ipv4 value-object

22/08 2015

1.1.0

1.1.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Development Requires

library ip immutable ipv6 ipv4 value-object

22/08 2015

1.0.0

1.0.0.0 https://github.com/darsyn/ip

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

  Sources   Download

MIT

The Development Requires

library ip immutable ipv6 ipv4 value-object