Retrieve DNS records for a given domain. Under the hood the package uses https://github.com/reactphp/reactphp for concurrent dns queries.
You can install the package via composer:
composer require gemz/dns
use Gemz\Dns\Dns;
// initialization
$dns = new Dns('gemz.io');
$dns = Dns::for('gemz.io');
// supported record types
// returns ["A", "CAA", "CNAME", "SOA", "TXT", "MX", "AAAA", "SRV", "NS", "PTR", "SSHFP"]
$dns = Dns::for('gemz.io')->allowedRecordTypes();
// get results for all record types
$dns = Dns::for('gemz.io')->records();
// get result for specific record(s)
$dns = Dns::for('gemz.io')->records(['A', 'CNAME']);
$dns = Dns::for('gemz.io')->records('A', 'MX', 'TXT');
// using a nameserver
$dns = Dns::for('gemz.io')->useNameServer('example.gemz.io')->records();
// sanitizing domain
$domain = Dns::for('https://gemz.io')->getDomain(); // gemz.io
// record type results
$dns = Dns::for('gemz.io')->records('A', 'NS');
// depending on the record type "data" will be a string or an array with different keys
// result is an array in form of:
[
"A" => [
["ttl" => 21599, "data" => "<ip>"]
],
"NS" => [
["ttl" => 21599, "data" => "<nameserver1>"],
["ttl" => 21599, "data" => "<nameserver2>"],
],
"MX" => [
["ttl" => 21599, "data" => ["priority" => 10, "target" => "<mx1>"]],
["ttl" => 21599, "data" => ["priority" => 20, "target" => "<mx2>"]],
]
];
composer test
composer test-coverage
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email stefan@sriehl.com instead of using the issue tracker.
Gemz.io is maintained by Stefan Riehl. You'll find all open source projects on Gemz.io github.
The MIT License (MIT). Please see License File for more information.