Search by

monovm / whois-laravel

monovm

Simple and fast domain whois lookup and availability checking for Laravel with a facade, config, caching and an artisan command.

Package info

github.com/monovm/laravel-whois

pkg:composer/monovm/whois-laravel

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 5

dev-main 2026-08-09 13:13 UTC

This package is not auto-updated.

Last update: 2026-10-19 11:21:16 UTC


README

Retrieve domain registration information and check domain availability via socket protocol โ€” with a facade, publishable config, optional result caching and an artisan command.

๐Ÿ“ฆ Requirements

  • PHP 8.0 or higher
  • Laravel 8, 9, 10, 11 or 12

๐Ÿ“œ 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

๐ŸŽ“ 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');
}

๐Ÿ”ฅ 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"
# }

โš™๏ธ 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.

๐Ÿงช 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);

๐ŸŒ Contributing

If you want to extend functionality or correct a bug, feel free to create a new pull request at Github's repository.

โš–๏ธ License

MIT

๐Ÿ’ป Support

For support, email dev@monovm.com.

MonoVM.com

Logo