PHP code example of jinomial / laravel-dns

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

    

jinomial / laravel-dns example snippets


'doh' => [
    'driver' => 'doh',
    'endpoint' => env('DOH_ENDPOINT', 'https://cloudflare-dns.com/dns-query'),
    'guzzle' => [
        'connect_timeout' => 0,
        'timeout' => 0,
        'verify' => true,
    ]
],

$response = Dns::query('ipv6.localhost.jinomial.com', 'aaaa');
print_r($response);

// > Response varies by driver

$response = Dns::socket('system')->query('ipv4.localhost.jinomial.com', 'a');

$response = Dns::query([
    [
        'name' => 'ipv6.localhost.jinomial.com',
        'type' => 'AAAA',
    ],
    [
        'name' => 'ipv4.localhost.jinomial.com',
        'type' => 'A',
    ],
]);

$promises = Dns::query($queries, null, ['async' => true]);
$response = Dns::unwrap($promises);

    /**
     * Application service provider bootstrap for package services.
     *
     * \App\Dns\Sockets\DnsResolver is my custom driver class I made.
     * The DnsManager needs to know how to construct it.
     */
    public function boot(): void
    {
        $dnsLoader = $this->app->get(\Jinomial\LaravelDns\DnsManager::class);
        $driverName = 'my-custom-driver';
        $dnsLoader->extend($driverName, function () use ($driverName) {
            return new \App\Dns\Sockets\DnsResolver($driverName);
        });
    }
bash
php artisan vendor:publish --provider="Jinomial\LaravelDns\DnsServiceProvider" --tag="laravel-dns-config"