DNS for Laravel
Quickstart
Quickstart
Install
composer require cboxdk/laravel-dns
The service provider is auto-discovered and works with zero configuration.
Look up a record
use Cbox\LaravelDns\Facades\Dns;
use Cbox\Dns\Enums\RecordType;
$response = Dns::lookup('example.com', RecordType::MX);
$response->values(); // ['mail.example.com']
$response->records; // list<Cbox\Dns\ValueObjects\DnsRecord>
Or from the command line:
php artisan dns:lookup example.com MX
Verify domain ownership
Ask the user to publish a TXT record at the challenge host, then verify it straight from the domain's authoritative nameservers:
$host = Dns::challengeHost('example.com'); // _cbox-challenge.example.com
// user publishes: _cbox-challenge.example.com TXT "your-token"
Dns::verifyDomain('example.com', 'your-token'); // true
As a validation rule on a form field:
use Cbox\LaravelDns\Rules\DomainVerified;
$request->validate([
'domain' => ['required', new DomainVerified($team->dns_token)],
]);
Diagnose a domain
php artisan dns:diagnose example.com
$report = Dns::diagnose('example.com');
$report->hasErrors(); // bool
$report->byCategory(); // findings grouped by category
Next steps
- Usage — the full facade, command, and rule reference.
- Configuration — switch transports, tune timeouts.
- Testing — stub records with zero network I/O.