gemorroj/whordap

WHOIS/RDAP client

1.0.1 2025-04-04 20:45 UTC

This package is auto-updated.

Last update: 2025-04-04 20:50:48 UTC


README

License Latest Stable Version Continuous Integration

Features:

  • WHOIS/RDAP info for domains, IPv4/IPv6, CIDR, ASN
  • Support national domains (президент.рф for example)
  • Follow to registrar WHOIS/RDAP servers (whois.crsnic.net -> whois.nic.ru for example)
  • Force custom WHOIS/RDAP server

Requirements:

  • PHP >= 8.2
  • ext-curl

Installation:

composer require gemorroj/whordap

Example:

<?php
use WhoRdap\NetworkClient\NetworkClient;
use WhoRdap\WhoRdap;
use WhoRdap\Response\DomainRegistrarResponse;
use WhoRdap\Response\DomainResponse;
use Psr\Log\NullLogger;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$logger = new NullLogger();
$cache = new FilesystemAdapter('whordap', 60); // install symfony/cache

$networkClient = new NetworkClient(cache: $cache, logger: $logger);
$whois = new WhoRdap($networkClient);
// $data = $whois->process('ru');
// $data = $whois->process('127.0.0.1');
// $data = $whois->process('192.168.0.0/24'); // CIDR
// $data = $whois->process('2001:0db8:85a3:0000:0000:8a2e:0370:7334');
// $data = $whois->process('AS220');
// $data = $whois->process('sirus.su', WhoisServer('whois.tcinet.ru', ServerTypeEnum::WHOIS)); // custom WHOIS server
// $data = $whois->process('sirus.su', WhoisServer('https://www.nic.ru/rdap', ServerTypeEnum::RDAP)); // custom RDAP server
$data = $whois->process('vk.com');
$actualResponse = $data instanceof DomainResponse && $data->registrarResponse instanceof DomainRegistrarResponse ? $data->registrarResponse : $data;
// echo $actualResponse->getResponseAsString();

print_r($data);
/*
WhoRdap\Response\DomainResponse Object
(
    [response] => WhoRdap\NetworkClient\WhoisResponse Object
        (
            [data] => Domain Name: VK.COM
   Registry Domain ID: 3206186_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.nic.ru
...
        )

    [server] => WhoRdap\Resource\Server Object
        (
            [server] => whois.verisign-grs.com
            [type] => WhoRdap\Resource\ServerTypeEnum Enum:string
                (
                    [name] => WHOIS
                    [value] => whois
                )

        )

    [registrarResponse] => WhoRdap\Response\DomainRegistrarResponse Object
        (
            [response] => WhoRdap\NetworkClient\WhoisResponse Object
                (
                    [data] => Domain Name: VK.COM
Registry Domain ID: 3206186_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.nic.ru
...
                )

            [server] => WhoRdap\Resource\Server Object
                (
                    [server] => whois.nic.ru
                    [type] => WhoRdap\Resource\ServerTypeEnum Enum:string
                        (
                            [name] => WHOIS
                            [value] => whois
                        )

                )

        )

)
 */

Notes: