- How do I install and set up spatie/laravel-rdap in a Laravel project?
- Run `composer require spatie/laravel-rdap` to install the package, then publish the config file with `php artisan vendor:publish --tag=rdap-config`. This generates a config file in `config/rdap.php` where you can adjust caching and timeout settings.
- Which Laravel versions does this package support?
- The package is officially tested with Laravel 9+. For Laravel 8, check the package changelog for compatibility notes, as minor Laravel updates may introduce breaking changes. PHP 8.1+ is required.
- Does this package support all TLDs (like .com, .org) for RDAP queries?
- RDAP coverage varies by TLD. While major registries like .com and .org support RDAP, some TLDs may not. Always verify TLD support via IANA’s RDAP registry or test with `Rdap::query('example.com')` before relying on it in production.
- How does caching work, and can I customize it?
- The package caches TLD server discovery (default: 1 week) and RDAP responses using Laravel’s cache (Redis, database, etc.). Customize cache duration or store in `config/rdap.php` under `tld_servers_cache` or use `Cache::tags()` for domain-specific invalidation.
- What happens if an RDAP endpoint times out or fails?
- The package includes configurable retries (default: 3 attempts) and timeouts (default: 5 seconds). For unreliable endpoints, increase retries in `config/rdap.php` under `domain_queries` or wrap queries in a `try-catch` block for custom fallbacks.
- Can I use this package for fraud detection or domain validation?
- Yes, RDAP provides structured JSON data for domain registration details (e.g., registrant, creation date, nameservers). Use the `Rdap::query('domain.com')` facade to fetch data, then validate fields like `status` or `events` in your fraud logic.
- How do I handle private or custom RDAP servers (e.g., internal registries)?
- Override the default RDAP endpoints in `config/rdap.php` by adding a `custom_endpoints` array. For example, map `example.com` to your internal RDAP server URL to bypass public registries.
- Does this package work with Laravel’s testing tools (Pest/PHPUnit)?
- Yes, mock Guzzle HTTP client for unit tests or use VCR (VCR for PHP) to record RDAP responses. For integration tests, verify edge cases like unsupported TLDs or rate-limited endpoints with custom test doubles.
- What are the performance implications of caching RDAP responses?
- Caching reduces network calls but may serve stale data if domains transfer frequently. Adjust TTL in `config/rdap.php` or use `Cache::tags()` to invalidate entries per domain. For high-volume apps, consider Redis for faster cache retrieval.
- Are there alternatives to spatie/laravel-rdap for RDAP queries?
- For lightweight needs, use PHP’s native `file_get_contents()` with RDAP endpoints (e.g., `https://rdap.verisign.com/com/v1/domain/example.com`). For Laravel-specific solutions, this package is the most maintained option. For WHOIS fallbacks, consider `rubix/mailbox` or custom WHOIS parsers.