vzhabonos/php-whois
Composer 安装命令:
composer require vzhabonos/php-whois
包简介
PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 7.2+ compatible
README 文档
README
PHP WHOIS client implementation. Sends the queries directly to the WHOIS services.
Use case
- Raw and parsed domain lookup
- Raw and parsed ASN routes lookup
- Direct queries to TLD/ASN hosts
- Extending and customizing the default hosts, parsers, etc.
- Proxying via CurlLoader
Installation
System requirements:
- PHP >= 7.2
- php-curl
- php-mbstring
- Open port 43 in firewall
Optional:
- php-intl
- php-memcached + Memcached server
Project requirements:
- PSR-4 autoloader
Composer:
composer require vzhabonos/php-whois
or composer.json:
"require": {
"vzhabonos/php-whois": "^1.0"
}
Usage
Domain lookup
How to get summary about domain:
<?php use Iodev\Whois\Factory; // Creating default configured client $whois = Factory::get()->createWhois(); // Checking availability if ($whois->isDomainAvailable("google.com")) { print "Bingo! Domain is available! :)"; } // Supports Unicode (converts to punycode) if ($whois->isDomainAvailable("почта.рф")) { print "Bingo! Domain is available! :)"; } // Getting raw-text lookup $response = $whois->lookupDomain("google.com"); print $response->text; // Getting parsed domain info $info = $whois->loadDomainInfo("google.com"); print_r([ 'Domain created' => date("Y-m-d", $info->creationDate), 'Domain expires' => date("Y-m-d", $info->expirationDate), 'Domain owner' => $info->owner, ]);
Exceptions on domain lookup:
<?php use Iodev\Whois\Factory; use Iodev\Whois\Exceptions\ConnectionException; use Iodev\Whois\Exceptions\ServerMismatchException; use Iodev\Whois\Exceptions\WhoisException; try { $whois = Factory::get()->createWhois(); $info = $whois->loadDomainInfo("google.com"); if (!$info) { print "Null if domain available"; exit; } print $info->domainName . " expires at: " . date("d.m.Y H:i:s", $info->expirationDate); } catch (ConnectionException $e) { print "Disconnect or connection timeout"; } catch (ServerMismatchException $e) { print "TLD server (.com for google.com) not found in current server hosts"; } catch (WhoisException $e) { print "Whois server responded with error '{$e->getMessage()}'"; }
Proxy with SOCKS5:
<?php use Iodev\Whois\Loaders\CurlLoader; use Iodev\Whois\Factory; $loader = new CurlLoader(); $loader->replaceOptions([ CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5, CURLOPT_PROXY => "127.0.0.1:1080", //CURLOPT_PROXYUSERPWD => "user:pass", ]); $whois = Factory::get()->createWhois($loader); var_dump([ 'ya.ru' => $whois->loadDomainInfo('ya.ru'), 'google.de' => $whois->loadDomainInfo('google.de'), ]);
TLD hosts customization:
<?php use Iodev\Whois\Factory; use Iodev\Whois\Modules\Tld\TldServer; $whois = Factory::get()->createWhois(); // Define custom whois host $customServer = new TldServer(".custom", "whois.nic.custom", false, Factory::get()->createTldParser()); // Or define the same via assoc way $customServer = TldServer::fromData([ "zone" => ".custom", "host" => "whois.nic.custom", ]); // Add custom server to existing whois instance $whois->getTldModule()->addServers([$customServer]); // Now it can be utilized $info = $whois->loadDomainInfo("google.custom"); var_dump($info);
TLD default/fallback servers:
<?php use Iodev\Whois\Factory; use Iodev\Whois\Modules\Tld\TldServer; $whois = Factory::get()->createWhois(); // Add default servers $matchedServers = $whois->getTldModule() ->addServers(TldServer::fromDataList([ ['zone' => '.*.net', 'host' => 'localhost'], ['zone' => '.uk.*', 'host' => 'localhost'], ['zone' => '.*', 'host' => 'localhost'], ])) ->matchServers('some.uk.net'); foreach ($matchedServers as $s) { echo "{$s->getZone()} {$s->getHost()}\n"; } // Matched servers + custom defaults: // // .uk.net whois.centralnic.com // .uk.net whois.centralnic.net // .uk.* localhost // .*.net localhost // .net whois.crsnic.net // .net whois.verisign-grs.com // .* localhost
ASN lookup
How to get summary using ASN number:
<?php use Iodev\Whois\Factory; $whois = Factory::get()->createWhois(); // Getting raw-text lookup $response = $whois->lookupAsn("AS32934"); print $response->text; // Getting parsed ASN info $info = $whois->loadAsnInfo("AS32934"); foreach ($info->routes as $route) { print_r([ 'route IPv4' => $route->route, 'route IPv6' => $route->route6, 'description' => $route->descr, ]); }
Response caching
Some TLD hosts are very limited for frequent requests. Use cache if in your case requests are repeating.
<?php use Iodev\Whois\Factory; use Iodev\Whois\Loaders\SocketLoader; use Iodev\Whois\Loaders\MemcachedLoader; $m = new Memcached(); $m->addServer('127.0.0.1', 11211); $loader = new MemcachedLoader(new SocketLoader(), $m); $whois = Factory::get()->createWhois($loader); // do something...
Develompment
Supported php versions are configured in docker-compose.yml
Common use cases:
- Set up & run all tests:
docker compose up --build - Run tests under specific php version:
docker compose up php-8.2_intl --build - Run scripts:
docker compose run php-8.2_intl bin/php-whois info google.com
Also see TESTS.md
Contributing
The project is open for pull requests, issues and feedback. Please read the CODE_OF_CONDUCT.md
vzhabonos/php-whois 适用场景与选型建议
vzhabonos/php-whois 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.26k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「parser」 「query」 「routes」 「domain」 「whois」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vzhabonos/php-whois 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vzhabonos/php-whois 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vzhabonos/php-whois 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Query filtering in your frontend
Anax Database Active Record module for model classes.
An MT940 bank statement parser for PHP
Database/ORM-agnostic query construction helper
Laravel integration for the jsonapi.org parser
统计信息
- 总下载量: 1.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-03