Laravel Whois
Simple and fast domain whois lookup and availability checking for Laravel with a facade, config, caching and an artisan command.
#:zap: Simple and Fast Domain Whois Lookup for Laravel :zap:
Retrieve domain registration information and check domain availability via socket protocol — with a facade, publishable config, optional result caching and an artisan command.
#:package: Requirements
- PHP 8.0 or higher
- Laravel 8, 9, 10, 11 or 12
#:scroll: Installation
You can install the package via composer:
composer require monovm/whois-laravel
The service provider and the Whois facade are registered automatically via package discovery.
Optionally publish the config file:
php artisan vendor:publish --tag=whois-config
#:mortar_board: Usage/Examples
#Checking availability
Whois::check() returns an associative array with domains as keys and statuses as values.
Current statuses: available, unavailable, premium, invalid, unknown.
use MonoVM\WhoisLaravel\Facades\Whois; // Single domain $result1 = Whois::check('monovm.com'); // ['monovm.com' => 'unavailable'] // Single domain without specifying TLD — popular TLDs from the config are looked up $result2 = Whois::check('monovm'); // ['monovm.com' => 'unavailable', 'monovm.net' => 'unavailable', 'monovm.org' => 'unavailable', 'monovm.info' => 'unavailable'] // Multiple domains $result3 = Whois::check(['monovm', 'google.com', 'bing']); // Custom popular TLDs for this call only $result4 = Whois::check('monovm', ['popularTLDs' => ['.io', '.dev']]);
#Full whois lookup
Whois::lookup() runs a full whois lookup for a single domain and returns a WhoisResult DTO:
use MonoVM\WhoisLaravel\Facades\Whois; $result = Whois::lookup('monovm.com'); $result->domain; // "monovm.com" $result->sld; // "monovm" $result->tld; // ".com" $result->valid; // true — the domain can be looked up $result->available; // false — availability via enhanced detection $result->message; // the whois server message $result->toArray(); // array representation, also JsonSerializable
#Shortcuts
use MonoVM\WhoisLaravel\Facades\Whois; // Availability as a boolean if (Whois::isAvailable('monovm.com')) { // ... } // Raw whois handler (never cached) $handler = Whois::handler('monovm.com'); $handler->getAvailabilityDetails(); // debug info about the availability detection
#Dependency injection
Prefer injection over the facade? Type-hint the service:
use MonoVM\WhoisLaravel\WhoisService; public function __invoke(WhoisService $whois) { $status = $whois->check('monovm.com'); }
#:fire: Artisan command
php artisan whois:lookup monovm.com google.com # +------------+-------------+ # | Domain | Status | # +------------+-------------+ # | monovm.com | unavailable | # | google.com | premium | # +------------+-------------+ php artisan whois:lookup monovm.com --json # { # "monovm.com": "unavailable" # }
#:gear: Configuration
config/whois.php:
return [ // Looked up when a domain is checked without a TLD (eg: "monovm") 'popular_tlds' => ['.com', '.net', '.org', '.info'], // Whois servers rate-limit aggressively; enable caching to serve // repeated lookups for the same domain from the cache. 'cache' => [ 'enabled' => env('WHOIS_CACHE_ENABLED', false), 'store' => env('WHOIS_CACHE_STORE'), // null = default cache store 'ttl' => env('WHOIS_CACHE_TTL', 300), // seconds 'prefix' => 'whois:', ], ];
Caching applies to check() and lookup(). handler() always performs a live lookup.
#:test_tube: Testing
composer test
The package ships a MonoVM\WhoisLaravel\Contracts\Client binding you can swap in your own tests to avoid
real network lookups:
$this->app->instance(\MonoVM\WhoisLaravel\Contracts\Client::class, $yourFakeClient);
#:globe_with_meridians: Contributing
If you want to extend functionality or correct a bug, feel free to create a new pull request at Github's repository.
#:balance_scale: License
#:computer: Support
For support, email dev@monovm.com.