PHPackages                             choval/whois - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. choval/whois

AbandonedProject[Utility &amp; Helpers](/categories/utility)

choval/whois
============

WHOIS wrapper for PHP with Async, get the country, owner and range of an IP.

v1.3.0(4y ago)5169MIT

Since Feb 25Compare

[ Source](https://github.com/choval/whois)[ Packagist](https://packagist.org/packages/choval/whois)[ RSS](/packages/choval-whois/feed)WikiDiscussions Synced 3d ago

READMEChangelog (9)Dependencies (2)Versions (10)Used By (0)

Choval/Whois
============

[](#chovalwhois)

Description
-----------

[](#description)

WHOIS wrapper for PHP with Async, get the country, owner and range of an IP.

Uses
----

[](#uses)

- Get the raw response from a WHOIS query
- Get the country of an IP address
- Get the owner of an IP address
- Get the range assigned to the IP address

Note:
This library does not cache results. Please implement a cache accordingly to avoid abusing WHOIS servers.
The `range` can be retrieve for an IP query and saved to a database to check before querying WHOIS servers again.

Requirements
------------

[](#requirements)

- whois command
- PHP 7.1+

Installation
------------

[](#installation)

```
composer install choval\whois
```

Usage
-----

[](#usage)

This can be used with ReactPHP or in regular blocking mode.

### With ReactPHP

[](#with-reactphp)

```
$loop = \React\EventLoop\Factory::create();
$whois = new \Choval\Whois\Factory($loop);
$query = $whois->query('8.8.8.8');
$query->run()     // Returns a promise
  ->then(function($query) {
    print_r( $query->getRaw() );
    print_r( $query->getCountry() );
    print_r( $query->getOwner() );
    print_r( $query->getRange() );
  });
$loop->run();
```

### Regular, blocking mode

[](#regular-blocking-mode)

```
$query = new \Choval\Whois\Query('8.8.8.8');
$query->run();
print_r( $query->getRaw() );
print_r( $query->getCountry() );
print_r( $query->getOwner() );
print_r( $query->getRange() );
```

Extras
------

[](#extras)

This library contains a few extra functions for handling IPv4 and IPv6.

### is\_ipv6

[](#is_ipv6)

```
use function \Choval\Whois\is_ipv6;

var_dump( is_ipv6('::1') );
// Returns true

var_dump( is_ipv6('1.1.1.1') );
// Returns false
```

### is\_ipv4

[](#is_ipv4)

```
use function \Choval\Whois\is_ipv4;

var_dump( is_ipv4('1.1.1.1') );
// Returns true

var_dump( is_ipv4('::1') );
// Returns false
```

### ip\_version

[](#ip_version)

```
use function \Choval\Whois\ip_version;

var_dump( ip_version('::1') );
// Returns string ipv6

var_dump( ip_version('1.1.1.1') );
// Returns string ipv4
```

### ip\_expand

[](#ip_expand)

This functions expands compressed IPv6 addresses. Partial IPv4 addresses used in ranges are expanded as well, and non-significant leading zeroes removed.

```
use function \Choval\Whois\ip_expand;

var_dump( ip_expand('::1') );
// Returns 0000:0000:0000:0000:0000:0000:0000:0001

var_dump( ip_expand('1::1') );
// Returns 0001:0000:0000:0000:0000:0000:0000:0001

var_dump( ip_expand('192.168.0') );
// Returns 192.168.0.0

var_dump( ip_expand('192.168.001.001') );
// Returns 192.168.1.1
```

### ip2hex

[](#ip2hex)

Converts an IP to it's hexadecimal representation.

```
use function \Choval\Whois\ip2hex;

var_dump( ip2hex('196.11.31.255') );
// Returns c40b1fff

var_dump( ip2hex('2a03:2880::') );
// Returns 2a032880000000000000000000000000
```

### parse\_range

[](#parse_range)

This functions parses a subnet or range (usually from the WHOIS response) and returns the from and to limits in IP, hex and binary format.
Binary format is suggested for database storage and hex format for comparisson.

```
use function \Choval\Whois\parse_range;

print_r( parse_range( '186.19.128/18') );
/*
Returns an array
     [range] => 186.19.128/18
      [from] => 186.19.128.0
        [to] => 186.19.191.255
  [bin_from] => (BINARY)
    [bin_to] => (BINARY)
  [hex_from] => ba138000
    [hex_to] => ba13bfff
*/

print_r( parse_range( '2a03:2880::/29') );
/*
Returns an array
     [range] => 2a03:2880::/29
      [from] => 2a03:2880:0000:0000:0000:0000:0000:0000
        [to] => 2a03:2887:ffff:ffff:ffff:ffff:ffff:ffff
  [bin_from] => (BINARY)
    [bin_to] => (BINARY)
  [hex_from] => 2a032880000000000000000000000000
    [hex_to] => 2a032887ffffffffffffffffffffffff
*/

print_r( parse_range( '196.11.31.0 - 196.11.31.255') );
/*
Returns an array
     [range] => 196.11.31.0 - 196.11.31.255
      [from] => 196.11.31.0
        [to] => 196.11.31.255
  [bin_from] => (BINARY)
    [bin_to] => (BINARY)
  [hex_from] => c40b1f00
    [hex_to] => c40b1fff
*/
```

### ip\_in\_range

[](#ip_in_range)

Checks if an IP ins in a range. The range is calculated using `parse_range`.

```
use function \Choval\Whois\ip_in_range;

var_dump( ip_in_range( '186.19.128.0', '186.19.128/18') );
// Returns true

var_dump( ip_in_range( '186.19.192.0', '186.19.128/18') );
// Returns false
```

Testsuite
---------

[](#testsuite)

```
git clone https://github.com/choval/whois.git --depth 1
composer install
./vendor/bin/phpunit --testdox
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Recently: every ~156 days

Total

9

Last Release

1579d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7e751254e7e7b319464bd6b51c51d9d2c5fedb4c2305ceaa580f9116cbc6a11?d=identicon)[choval](/maintainers/choval)

---

Top Contributors

[![choval](https://avatars.githubusercontent.com/u/794926?v=4)](https://github.com/choval "choval (21 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/choval-whois/health.svg)

```
[![Health](https://phpackages.com/badges/choval-whois/health.svg)](https://phpackages.com/packages/choval-whois)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
