monovm / whois-php
This PHP package enables developers to retrieve domain registration information and check domain availability via socket protocol. It's a useful tool for web developers and domain name registrars.
Requires
- php: >=7.4
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.7
README
This PHP package enables developers to retrieve domain registration information and check domain availability via socket protocol. It's a useful tool for web developers and domain name registrars.
based on WHMCS Whois class.
📜 Installation
You can install the package via composer:
composer require monovm/whois-php
▶️ Checker class
You can use this class to check one or multiple domains availability.
🎓 Usage/Examples
use MonoVM\WhoisPhp\Checker; // Single Domain whois $result1 = Checker::whois('monovm.com'); // Single Domain whois without specifying TLD $result2 = Checker::whois('monovm'); // Multiple domains whois $result3 = Checker::whois(['monovm','google.com','bing']);
An associative array with domains as keys and status as values. Current statuses: available, unavailable, premium
$result1: ['monovm.com'=>'unavailable']
$result2: ['monovm.com'=>'unavailable','monovm.net'=>'unavailable','monovm.org'=>'unavailable','monovm.info'=>'unavailable']
$result3: [
'monovm.com'=>'premium',
'monovm.net'=>'unavailable',
'monovm.org'=>'unavailable',
'monovm.info'=>'unavailable',
'google.com'=>'premium',
'bing.com'=>'unavailable',
'bing.net'=>'unavailable',
'bing.org'=>'available',
'bing.info'=>'unavailable'
]
🔥 popularTLDs Configuration
When TLD is not specified in the domain string (eg:monovm instead of monovm.com), Checker class will automatically lookup a list of popular TLDs for the entered name.
You can customize this list by passing an options array as second parameter of whois method.
use MonoVM\WhoisPhp\Checker; $result = Checker::whois('monovm', ['popularTLDs' => ['.com', '.net', '.org', '.info']]);
▶️ WhoisHandler class
🎓 Usage/Examples
use MonoVM\WhoisPhp\WhoisHandler; $whoisHandler = WhoisHandler::whois('monovm.com');
Available methods:
After initiating the handler method you will have access to the following methods:
🟢 isAvailable()
method takes a single parameter, the domain name, as a string value. If the domain is
available for registration, the method returns a boolean true value. If the domain is already registered, the method
returns a boolean false value.
$available = $whoisHandler->isAvailable();
🟢 isValid()
method checks whether the entered domain name is valid and can be looked up or not.
$valid = $whoisHandler->isValid();
🟢 The getWhoisMessage()
method is used to retrieve the WHOIS information of a domain. This method returns
a string that includes the WHOIS server message, which may contain information about the availability and validation of
the domain, as well as its WHOIS information.
$message = $whoisHandler->getWhoisMessage();
🟢 getTld()
method is used to extract the top level domain (TLD) of a given domain. For example, if the
domain name passed to the handler is "monovm.com", the method will return "com" as the TLD. Similarly, if the domain
name is "monovm.co.uk", the method will return "co.uk" as the TLD.
$tld = $whoisHandler->getTld();
🟢 getSld()
method returns the second level domain of the entered domain as a string. The second level
domain is the part of the domain name that comes before the top level domain, and it is typically the main part of the
domain that identifies the website or organization. For example, in the domain name "monovm.com", the second level
domain is "monovm".
$sld = $whoisHandler->getSld();
🌐 Whois Server List
Almost all TLDs are supported.
⚖️ License
💻 Support
For support, email dev@monovm.com.