Skip to content

alexkart/network-utilities

 
 

Yii network utilities


The package contains various network utilities useful for:

  • Getting info about IP address
  • Checking if IP is in a certain range
  • Expanding IP v6
  • Converiting IP to bits representation

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage

General usage

IpHelper

use Yiisoft\NetworkUtilities\IpHelper;

// checking IP version
$version = IpHelper::getIpVersion('192.168.1.1');
if ($version === IpHelper::IPV4) {
    // ...
}

// checking if IP is in a certain range
if (!IpHelper::inRange('192.168.1.21/32', '192.168.1.0/24')) {
    throw new \RuntimeException('Access denied!');
}

// expanding IP v6
echo IpHelper::expandIPv6('2001:db8::1');

// converting IP to bits representation
echo IpHelper::ip2bin('192.168.1.1');

// gets bits from CIDR Notation
echo IpHelper::getCidrBits('192.168.1.21/32');

DnsHelper

use Yiisoft\NetworkUtilities\DnsHelper;

// checking DNS record availability
if(!DnsHelper::checkA('yiiframework.com')) {
  // record not found
}

About

Network related utilities

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%