{"id":13584642,"url":"https://github.com/io-developer/php-whois","last_synced_at":"2025-05-15T07:06:40.495Z","repository":{"id":15691457,"uuid":"57904368","full_name":"io-developer/php-whois","owner":"io-developer","description":"PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 8.0 compatible (5.4+ old versions)","archived":false,"fork":false,"pushed_at":"2024-02-05T12:22:43.000Z","size":1228,"stargazers_count":457,"open_issues_count":41,"forks_count":122,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-05-10T20:28:29.565Z","etag":null,"topics":["asn","asnumber","curl","domain","info","lookup","php","proxy","routes","socks5","tld","whois"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/io-developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-05-02T16:36:26.000Z","updated_at":"2025-05-05T14:49:34.000Z","dependencies_parsed_at":"2023-11-07T17:10:52.791Z","dependency_job_id":"8efc4591-3a89-481f-ac65-1c629bf1f8b7","html_url":"https://github.com/io-developer/php-whois","commit_stats":{"total_commits":475,"total_committers":25,"mean_commits":19.0,"dds":0.1663157894736842,"last_synced_commit":"ea4cf52832fe8ff56fc4937138467819aa2829c1"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-developer%2Fphp-whois","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-developer%2Fphp-whois/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-developer%2Fphp-whois/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/io-developer%2Fphp-whois/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/io-developer","download_url":"https://codeload.github.com/io-developer/php-whois/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253601034,"owners_count":21934248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asn","asnumber","curl","domain","info","lookup","php","proxy","routes","socks5","tld","whois"],"created_at":"2024-08-01T15:04:24.794Z","updated_at":"2025-05-15T07:06:40.384Z","avatar_url":"https://github.com/io-developer.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# PHP WHOIS\n\n[![PHP version](https://img.shields.io/badge/php-%3E%3D7.2-8892BF.svg)](https://secure.php.net/)\n[![Packagist](https://img.shields.io/packagist/v/io-developer/php-whois.svg)](https://packagist.org/packages/io-developer/php-whois)\n\nPHP WHOIS client implementation. Sends the queries directly to the WHOIS services.\n\n## Use case\n * Raw and parsed domain lookup\n * Raw and parsed ASN routes lookup\n * Direct queries to TLD/ASN hosts\n * Extending and customizing the default hosts, parsers, etc.\n * Proxying via CurlLoader\n\n## Installation\n\n##### System requirements:\n* PHP \u003e= __7.2__ (old versions supports __5.4+__)\n* php-curl\n* php-mbstring\n* Open port __43__ in firewall\n\nOptional:\n* php-intl\n* php-memcached + Memcached server\n\n##### Project requirements:\n* PSR-4 autoloader\n\n##### Composer:\n````\ncomposer require io-developer/php-whois\n````\nor composer.json:\n````\n\"require\": {\n    \"io-developer/php-whois\": \"^4.0\"\n}\n````\n\n\n## Usage\n\n### Domain lookup\n\n##### How to get summary about domain:\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Factory;\n\n// Creating default configured client\n$whois = Factory::get()-\u003ecreateWhois();\n\n// Checking availability\nif ($whois-\u003eisDomainAvailable(\"google.com\")) {\n    print \"Bingo! Domain is available! :)\";\n}\n\n// Supports Unicode (converts to punycode)\nif ($whois-\u003eisDomainAvailable(\"почта.рф\")) {\n    print \"Bingo! Domain is available! :)\";\n}\n\n// Getting raw-text lookup\n$response = $whois-\u003elookupDomain(\"google.com\");\nprint $response-\u003etext;\n\n// Getting parsed domain info\n$info = $whois-\u003eloadDomainInfo(\"google.com\");\nprint_r([\n    'Domain created' =\u003e date(\"Y-m-d\", $info-\u003ecreationDate),\n    'Domain expires' =\u003e date(\"Y-m-d\", $info-\u003eexpirationDate),\n    'Domain owner' =\u003e $info-\u003eowner,\n]);\n\n```\n\n##### Exceptions on domain lookup:\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Factory;\nuse Iodev\\Whois\\Exceptions\\ConnectionException;\nuse Iodev\\Whois\\Exceptions\\ServerMismatchException;\nuse Iodev\\Whois\\Exceptions\\WhoisException;\n\ntry {\n    $whois = Factory::get()-\u003ecreateWhois();\n    $info = $whois-\u003eloadDomainInfo(\"google.com\");\n    if (!$info) {\n        print \"Null if domain available\";\n        exit;\n    }\n    print $info-\u003edomainName . \" expires at: \" . date(\"d.m.Y H:i:s\", $info-\u003eexpirationDate);\n} catch (ConnectionException $e) {\n    print \"Disconnect or connection timeout\";\n} catch (ServerMismatchException $e) {\n    print \"TLD server (.com for google.com) not found in current server hosts\";\n} catch (WhoisException $e) {\n    print \"Whois server responded with error '{$e-\u003egetMessage()}'\";\n}\n```\n\n##### Proxy with SOCKS5:\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Loaders\\CurlLoader;\nuse Iodev\\Whois\\Factory;\n\n$loader = new CurlLoader();\n$loader-\u003ereplaceOptions([\n    CURLOPT_PROXYTYPE =\u003e CURLPROXY_SOCKS5,\n    CURLOPT_PROXY =\u003e \"127.0.0.1:1080\",\n    //CURLOPT_PROXYUSERPWD =\u003e \"user:pass\",\n]);\n$whois = Factory::get()-\u003ecreateWhois($loader);\n\nvar_dump([\n    'ya.ru' =\u003e $whois-\u003eloadDomainInfo('ya.ru'),\n    'google.de' =\u003e $whois-\u003eloadDomainInfo('google.de'),\n]);\n```\n\n##### TLD hosts customization:\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Factory;\nuse Iodev\\Whois\\Modules\\Tld\\TldServer;\n\n$whois = Factory::get()-\u003ecreateWhois();\n\n// Define custom whois host\n$customServer = new TldServer(\".custom\", \"whois.nic.custom\", false, Factory::get()-\u003ecreateTldParser());\n\n// Or define the same via assoc way\n$customServer = TldServer::fromData([\n    \"zone\" =\u003e \".custom\",\n    \"host\" =\u003e \"whois.nic.custom\",\n]);\n\n// Add custom server to existing whois instance\n$whois-\u003egetTldModule()-\u003eaddServers([$customServer]);\n\n// Now it can be utilized\n$info = $whois-\u003eloadDomainInfo(\"google.custom\");\n\nvar_dump($info);\n```\n\n##### TLD default/fallback servers:\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Factory;\nuse Iodev\\Whois\\Modules\\Tld\\TldServer;\n\n$whois = Factory::get()-\u003ecreateWhois();\n\n// Add default servers\n$matchedServers = $whois-\u003egetTldModule()\n    -\u003eaddServers(TldServer::fromDataList([\n        ['zone' =\u003e '.*.net', 'host' =\u003e 'localhost'],\n        ['zone' =\u003e '.uk.*', 'host' =\u003e 'localhost'],\n        ['zone' =\u003e '.*', 'host' =\u003e 'localhost'],\n    ]))\n    -\u003ematchServers('some.uk.net');\n\nforeach ($matchedServers as $s) {\n    echo \"{$s-\u003egetZone()}  {$s-\u003egetHost()}\\n\";\n}\n\n// Matched servers + custom defaults:\n//\n// .uk.net  whois.centralnic.com\n// .uk.net  whois.centralnic.net\n// .uk.*  localhost\n// .*.net  localhost\n// .net  whois.crsnic.net\n// .net  whois.verisign-grs.com\n// .*  localhost\n```\n\n### ASN lookup\n\n##### How to get summary using ASN number:\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Factory;\n\n$whois = Factory::get()-\u003ecreateWhois();\n\n// Getting raw-text lookup\n$response = $whois-\u003elookupAsn(\"AS32934\");\nprint $response-\u003etext;\n\n// Getting parsed ASN info\n$info = $whois-\u003eloadAsnInfo(\"AS32934\");\nforeach ($info-\u003eroutes as $route) {\n    print_r([\n        'route IPv4' =\u003e $route-\u003eroute,\n        'route IPv6' =\u003e $route-\u003eroute6,\n        'description' =\u003e $route-\u003edescr,\n    ]);   \n}\n\n```\n\n### Response caching\nSome TLD hosts are very limited for frequent requests. Use cache if in your case requests are repeating.\n```php\n\u003c?php\n\nuse Iodev\\Whois\\Factory;\nuse Iodev\\Whois\\Loaders\\SocketLoader;\nuse Iodev\\Whois\\Loaders\\MemcachedLoader;\n\n$m = new Memcached();\n$m-\u003eaddServer('127.0.0.1', 11211);\n$loader = new MemcachedLoader(new SocketLoader(), $m);\n\n$whois = Factory::get()-\u003ecreateWhois($loader);\n// do something...\n```\n\n\n## Develompment\nSupported php versions are configured in `docker-compose.yml`\n\nCommon use cases:\n1. Set up \u0026 run all tests: `docker compose up --build`\n2. Run tests under specific php version: `docker compose up php-8.2_intl --build`\n3. Run scripts: `docker compose run php-8.2_intl bin/php-whois info google.com`\n\nAlso see **TESTS.md**\n\n\n## Contributing\n\nThe project is open for pull requests, issues and feedback. Please read the CODE_OF_CONDUCT.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fio-developer%2Fphp-whois","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fio-developer%2Fphp-whois","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fio-developer%2Fphp-whois/lists"}