PHP code example of labrodev / laravel-domain-verifier

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

    

labrodev / laravel-domain-verifier example snippets


use Labrodev\DomainVerifier\Services\VerificationTokenGenerator;

$token = (new VerificationTokenGenerator)();

use Labrodev\DomainVerifier\Services\DnsResolver;
use Labrodev\DomainVerifier\Services\OwnerVerifier;

$ownerVerifier = new OwnerVerifier(new DnsResolver);

// "Add a TXT record on @ with this value:"
$ownerVerifier->expectedRecord($token); // "domain-verify={token}"

if ($ownerVerifier('example.com', $token)) {
    // mark the domain as verified
}

$result = $ownerVerifier->verify('example.com', $token);

$result->verified;        // bool
$result->expected;        // the TXT value that was looked for
$result->observedRecords; // every TXT record actually found on the domain

use Labrodev\DomainVerifier\Services\CnameVerifier;
use Labrodev\DomainVerifier\Services\DnsResolver;

$cnameVerifier = new CnameVerifier(new DnsResolver);

if ($cnameVerifier('status.example.com', 'pages.my-platform.dev')) {
    // the CNAME is in place
}

use Labrodev\DomainVerifier\Services\DnsResolver;

$dnsResolver = new DnsResolver;

$dnsResolver->txtRecords('example.com');          // list<string>, quotes and chunking normalized
$dnsResolver->cnameRecords('status.example.com'); // list<string>, trailing dots stripped
bash
php artisan vendor:publish --tag=domain-verifier-config