PHP code example of gemz / dns

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

    

gemz / dns example snippets


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>"]],
  ]
];