- How do I install setechsolutions/php-whois in a Laravel app?
- Run composer require setechsolutions/php-whois. Laravel auto-discovery registers the service provider and the Whois facade, so you can call Whois::lookup('example.com') without manual registration. If you need to change defaults, publish config/whois.php with the standard vendor:publish command and set WHOIS_MODE and WHOIS_TIMEOUT. No other setup is required for a basic lookup.
- Can I use this WHOIS package without Laravel?
- Yes. The library has no dependency on Laravel and exposes a framework-agnostic PHP API, so it works in plain PHP scripts, CLI tools, Symfony applications, and queue workers. The service provider and Whois facade are optional conveniences for Laravel only; elsewhere you instantiate and call the underlying classes directly. The same code path is used either way.
- How do I check if a domain is available with this package?
- Call Whois::lookup('example.com') and inspect the result: it returns a DomainInfo object when the domain is registered and null when it is not. isAvailable() is the boolean counterpart for the unregistered case. Always check for null before reading registration fields, because availability is expressed by the absence of a result, not by a property on the result.
- Why does expiresAt() return null, and how should I handle it?
- DomainInfo accessors such as createdAt(), expiresAt(), and updatedAt() return null when the registry does not publish that field, which is common for some TLDs. Also, lookup() itself returns null for unregistered domains, so a chain like $info->expiresAt()->format('Y-m-d') can fail fatally. Guard both levels: check the lookup result and null-check the accessor before formatting. Store or display a fallback value when the date is unknown.
- What exceptions does setechsolutions/php-whois throw?
- All package exceptions extend WhoisException, with meaningful subtypes: InvalidDomainException, UnsupportedTldException, ConnectionException, and RateLimitException. InvalidDomainException is raised before any network call, so malformed input never reaches a registry. Catch the specific subtypes to map failures onto HTTP status codes or retry logic, and catch WhoisException as a fallback. Null returns are not exceptions, so they need separate handling.
- Does this package use RDAP or WHOIS, and can I configure the server and timeout?
- The library tries RDAP first and falls back to WHOIS, which gives you more structured data where registries support it. Behavior is controlled by the publishable config/whois.php file, including the WHOIS_MODE and WHOIS_TIMEOUT environment variables. The default timeout is 30 seconds, so lower it if you call the package from a request path. Per-registry server availability and schema differences still affect results.
- Which PHP and Laravel versions are supported?
- The documented support matrix covers PHP 7.2.5 through 8.5 and Laravel 6 through 13, with CI testing on the lowest and highest PHP version for each Laravel release. Because the package has no Laravel dependency, the PHP support range matters even when you use it outside a framework. Check the repository's test matrix before pinning to edge versions.
- Is it safe to run WHOIS lookups directly in a web request?
- Lookups are synchronous, blocking network I/O with a 30-second default timeout, so a slow or unresponsive registry can hold a PHP worker for a long time. For production, push lookups to a queue job, set a shorter WHOIS_TIMEOUT, and handle RateLimitException with backoff. Since 5.0 removed the built-in Memcached loader, cache results yourself to cut latency and registry rate-limit pressure. Avoid calling the package inline on high-traffic pages without a cache in front.
- How do I test code that uses this package without hitting live WHOIS servers?
- Avoid live lookups in tests because they are slow, rate-limited, and non-deterministic. Wrap the lookup behind a small interface or service class in your application and swap in a stub that returns DomainInfo objects built from fixture data; DomainInfo is JSON-serializable via toArray(), which makes good fixtures. In Laravel you can also mock the Whois facade. The package does not document a built-in fake, so your own wrapper is the reliable seam.
- Is 5.0 a drop-in replacement for io-developer/php-whois, and what changed?
- No. Version 5.0 is a greenfield API: the Iodev\Whois namespace is removed, methods and properties were renamed or converted to accessors, mode constants and exceptions changed, and the replace entry for io-developer/php-whois was dropped. There is no deprecation bridge, so every call site and test touching lookup data must be updated using the migration table. If you depend on it as a transparent substitute, stay pinned to ^4.2 on the 4.x branch and evaluate alternatives before upgrading.