PHP code example of spatie / laravel-rdap

1. Go to this page and download the library: Download spatie/laravel-rdap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spatie / laravel-rdap example snippets




use Carbon\CarbonInterval;

return [
    /*
     * When making an RDAP query, we first have got to make a request to determine
     *  the server responsible for the tld of the query. Here you can specify
     * how long we should cache the server URLs.
     */

    'tld_servers_cache' => [
        'store_name' => null,
        'duration_in_seconds' => CarbonInterval::week()->totalSeconds,
    ],

    /*
     * RDAP seem to be a bit unreliable when responding to domain queries. 
     * We solve this by attempting a request to RDAP a couple of times 
     * until we get a response.
     */
    'domain_queries' => [
        /*
         * How long we should wait per attempt to get a response
         */
        'timeout_in_seconds' => 5,
        /*
         * How many times we should attempt getting a response
         */
        'retry_times' => 3,
        /*
         * The time between attempts
         */
        'sleep_in_milliseconds_between_retries' => 1000,
    ],
];

use Spatie\Rdap\Facades\Rdap;

$domain = Rdap::domain('google.com'); // returns an instance of `Spatie\Rdap\Responses\DomainResponse`

$domain = Rdap::domain(
   'google.com'
   timeoutInSecons: 10,
   retryTimes: 4,
   sleepInMillisecondsBetweenRetries: 2000,       
);

$properties = $domain->all(); // returns an array

$domain->get('objectClassName'); // returns 'domain'

$domain->get('links.0.value'); // returns 'https://rdap.verisign.com/com/v1/domain/GOOGLE.COM'

use Spatie\Rdap\Enums\DomainStatus;

$domain->hasStatus(DomainStatus::ClientTransferProhibited); // returns a boolean

use Spatie\Rdap\Facades\Rdap;

Rdap::domainIsSupported('freek.dev'); // returns true;
Rdap::domainIsSupported('spatie.be'); // returns false because 'be' isn't currently a supported tld;

use Spatie\Rdap\Facades\Rdap;

$domain = Rdap::domain('google.com'); // returns an instance of `Spatie\Rdap\Responses\DomainResponse`

$rdapDns = Spatie\Rdap\Facades\Rdap::dns();

$rdapDns->getServerForDomain('google.com'); // returns "https://rdap.verisign.com/com/v1/"

$rdapDns->getServerForTld('com'); // returns "https://rdap.verisign.com/com/v1/"

$rdapDns->supportedTlds(); // returns an array with all supported TLDs
bash
php artisan vendor:publish --tag="rdap-config"