PHP code example of artem-baranovskyi / dns-lookup

1. Go to this page and download the library: Download artem-baranovskyi/dns-lookup 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/ */

    

artem-baranovskyi / dns-lookup example snippets


composer 

        /*
         * Package Service Providers...
         */
        DnsLookupServiceProvider::class,

    'aliases' => Facade::defaultAliases()->merge([
        'DnsLookup' => ArtemBaranovskyi\DnsLookup\Facades\DnsLookupFacade::class,
    ])->toArray(),

use ArtemBaranovskyi\DnsLookup\Facades\DnsLookupFacade;
...
    $domain = 'example.com';
    $dnsRecords = DnsLookupFacade::getDnsRecords($domain, 'array'); // use any from 'array', 'collection', 'json'
    dd($dnsRecords);

use ArtemBaranovskyi\DnsLookup\Facades\DnsLookupFacade;

    $domain = 'example.com';
    $dnsLookup = app(DnsLookup::class);
    $dnsRecords = $dnsLookup->getDnsRecords($domain, 'array'); // use any from 'array', 'collection', 'json'
    dd($dnsRecords);

try {
    $dnsRecords = $dnsLookup->getDnsRecords($domain, $format);
    // Use the DNS records
} catch (Exception $e) {
    echo "An error occurred: " . $e->getMessage();
}