PHP WHOIS client implementation. Provides raw-text and parsed answers. Sends WHOIS queries to real service via port 43
- PHP >= 5.4 (compatible with 7.0 up to nightly)
- intl
Via Composer cli command
composer require io-developer/php-whois
Or via composer.json
"require": {
"io-developer/php-whois": "^2.3.0"
}
<?php
require_once '../vendor/autoload.php';
use Iodev\Whois\Whois;
$whois = Whois::create();
<?php
use Iodev\Whois\Whois;
if (Whois::create()->isDomainAvailable("google.com")) {
echo "Bingo! Domain is available! :)";
}
<?php
use Iodev\Whois\Whois;
$response = Whois::create()->lookupDomain("google.com");
echo $response->getText();
<?php
use Iodev\Whois\Whois;
$info = Whois::create()->loadDomainInfo("google.com");
echo "Domain created: " . date("Y-m-d", $info->getCreationDate());
echo "Domain expires: " . date("Y-m-d", $info->getExpirationDate());
echo "Domain owner: " . $info->getOwner();
<?php
use Iodev\Whois\Whois;
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 = Whois::create(null, $loader);
<?php
use Iodev\Whois\Whois;
use Iodev\Whois\Exceptions\ConnectionException;
use Iodev\Whois\Exceptions\ServerMismatchException;
$whois = Whois::create();
try {
$info = $whois->loadDomainInfo("google.com");
if (!$info) {
echo "Null if domain available";
exit;
}
echo $info->getDomainName() . " expires at: " . date("d.m.Y H:i:s", $info->getExpirationDate());
} catch (ConnectionException $e) {
echo "Disconnect or connection timeout";
} catch (ServerMismatchException $e) {
echo "Domain zone servers (.com for google.com) not found in current ServerProvider whois hosts";
}
<?php
use Iodev\Whois\Whois;
$response = Whois::create()->lookupDomain("google.com");
echo $response->getText();
<?php
use Iodev\Whois\Whois;
$info = Whois::create()->loadDomainInfo("google.com");
$resp = $info->getResponse();
echo "WHOIS response for '{$resp->getDomain()}':\n{$resp->getText()}";
<?php
use Iodev\Whois\Server;
use Iodev\Whois\Whois;
use Iodev\Whois\Parsers\CommonParser;
$whois = Whois::create();
// Define custom whois host
$customServer = new Server(".co", "whois.nic.co", false, new CommonParser());
// Or define the same via assoc way
$customServer = Server::fromData([
"zone" => ".co",
"host" => "whois.nic.co",
]);
// Append to existing provider
$whois->getServerProvider()->addOne($customServer);
// Now you can load info
$info = $whois->loadDomainInfo("google.co");
var_dump($info);