2017 © Pedro Peláez
 

library ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

image

longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

  • Sunday, October 23, 2016
  • by LONGMAN
  • Repository
  • 9 Watchers
  • 131 Stars
  • 22,256 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 10 Forks
  • 1 Open issues
  • 7 Versions
  • 18 % Grown

The README.md

PHP IP Tools

Build Status Latest Stable Version Total Downloads Downloads Month License, (*1)

Universal IP Tools for manipulation on IPv4 and IPv6., (*2)

Require this package with Composer

Install this package through Composer. Edit your project's composer.json file to require longman/ip-tools., (*3)

Create composer.json file:, (*4)

{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "longman/ip-tools": "~1.1.0"
    }
}

And run composer update, (*5)

Or run a command in your command line:, (*6)

composer require longman/ip-tools

Usage

<?php
$loader = require __DIR__.'/vendor/autoload.php';

use Longman\IPTools\Ip;

// Validating
$status = Ip::isValid('192.168.1.1'); // true

$status = Ip::isValid('192.168.1.256'); // false


// ip2long, long2ip

/// IPv4
$long = Ip::ip2long('192.168.1.1'); // 3232235777

$dec = Ip::long2ip('3232235777'); // 192.168.1.1

/// IPv6
$long = Ip::ip2long('fe80:0:0:0:202:b3ff:fe1e:8329'); // 338288524927261089654163772891438416681

$dec = Ip::long2ip('338288524927261089654163772891438416681', true); // fe80::202:b3ff:fe1e:8329


// Matching

/// IPv4
$status = Ip::match('192.168.1.1', '192.168.1.*'); // true

$status = Ip::match('192.168.1.1', '192.168.*.*'); // true

$status = Ip::match('192.168.1.1', '192.168.*.*'); // true

$status = Ip::match('192.168.1.1', '192.168.0.*'); // false


$status = Ip::match('192.168.1.1', '192.168.1/24'); // true

$status = Ip::match('192.168.1.1', '192.168.1.1/255.255.255.0'); // true

$status = Ip::match('192.168.1.1', '192.168.0/24'); // false

$status = Ip::match('192.168.1.1', '192.168.0.0/255.255.255.0'); // false


$status = Ip::match('192.168.1.5', '192.168.1.1-192.168.1.10'); // true

$status = Ip::match('192.168.5.5', '192.168.1.1-192.168.10.10'); // true

$status = Ip::match('192.168.5.5', '192.168.6.1-192.168.6.10');


$status = Ip::match('192.168.1.1', array('122.128.123.123', '192.168.1.*', '192.168.123.124')); // true

$status = Ip::match('192.168.1.1', array('192.168.123.*', '192.168.123.124'));

/// IPv6

$status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // true

$status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // true

$status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652',
                    '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:9999'); // true


$status = Ip::match('2001:cdba:0000:0000:0000:0000:3258:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // false

$status = Ip::match('2001:cdba:0000:0000:0000:1234:3258:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // false

$status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:7778',
                    '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:7777'); // false


This code is available on Github. Pull requests are welcome., (*7)

Troubleshooting

If you like living on the edge, please report any bugs you find on the PHP IP Tools issues page., (*8)

Contributing

See CONTRIBUTING.md for information., (*9)

License

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

Credits

Full credit list in CREDITS, (*11)

The Versions

23/10 2016

dev-master

9999999-dev https://github.com/akalongman/php-ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-bcmath *

 

The Development Requires

ip mask tools utilities ipv6 ipv4 compare subnet match

23/10 2016

1.2.1

1.2.1.0 https://github.com/akalongman/php-ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-bcmath *

 

The Development Requires

ip mask tools utilities ipv6 ipv4 compare subnet match

18/10 2016

1.2.0

1.2.0.0 https://github.com/akalongman/php-ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-bcmath *

 

The Development Requires

ip mask tools utilities ipv6 ipv4 compare subnet match

17/11 2015

1.1.1

1.1.1.0 https://github.com/akalongman/php-ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-bcmath *

 

The Development Requires

ip mask tools utilities ipv6 ipv4 compare subnet match

16/11 2015

1.1.0

1.1.0.0 https://github.com/akalongman/php-ip-tools

PHP profiler library

  Sources   Download

MIT

The Requires

  • php >=5.5
  • ext-bcmath *

 

The Development Requires

profiler debugger

12/11 2015

1.0.1

1.0.1.0 https://github.com/akalongman/php-ip-tools

PHP profiler library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

profiler debugger

12/11 2015

1.0.0

1.0.0.0 https://github.com/akalongman/php-ip-tools

PHP profiler library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

profiler debugger