PHP Classes
elePHPant
Icontem

Redbox DNS: Resolve domains and get other DNS records

Recommend this page to a friend!
  Info   View files Example   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-09-10 (16 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 171 This week: 11All time: 8,229 This week: 60Up
Version License PHP version Categories
redbox-dns 1.1MIT/X Consortium ...5.4Networking, PHP 5
Description Author

This is a simple class that can resolve domains and get other DNS records.

It can send queries to the default DNS to get the records for a given domain.

The DNS query results will be returned as an array.

  Performance   Level  
Name: Johnny Mast <contact>
Classes: 7 packages by
Country: The Netherlands The Netherlands
Innovation award
Innovation award
Nominee: 3x

Details

Build Status Scrutinizer Code Quality Code Coverage Twitter URL

Redbox-dns

Redbox-dns can be used to quickly query dns records a given domain. The API it self is extremely easy to use but you can always check out the examples directory for some examples.

Examples

In the examples directory you find usecases on how you can this class. Below you find an extremely easy way of receiving the mx records for Google.com and print them out. You can find this example once again in the examples directory.

$resolver = new \Redbox\DNS\Resolver();
$resolver->resolve('google.com', DNS_MX);

foreach($resolver as $record) {
    if ($record['type'] == 'MX')
        echo $record['type'] . ' ' . $record['pri'] . ' '. $record['target']."\n";
};

*ouput*

$ php ./mxrecords.php
MX 30 alt2.aspmx.l.google.com
MX 20 alt1.aspmx.l.google.com
MX 40 alt3.aspmx.l.google.com
MX 50 alt4.aspmx.l.google.com
MX 10 aspmx.l.google.com

Resolve Options

The second parameter to the resolve method can be used to define the desired record type to return. Below is a list of the available record types.

| Type | Record Type | Description | |:-----------|:--------------| :----------------------------------------------------------------| | DNS_ALL | ALL | Iteratively query the name server for each available record type | | DNS_A | A | IPv4 Address Resource | | DNS_CNAME | CNAME | Alias (Canonical Name) Resource | | DNS_HINFO | HINFO | Host Info Resource | | DNS_MX | MX | Mail Exchanger Resource | | DNS_NS | NS | Authoritative Name Server Resource | | DNS_PTR | PTR | Pointer Resource (Reverse DNS) | | DNS_SOA | SOA | Start of Authority Resource | | DNS_TXT | TXT | Text Resource | | DNS_AAAA | AAAA | Pv6 Address Resource | | DNS_SRV | SRV | Service record (SRV record) | | DNS_NAPTR | NAPTR | Name Authority Pointer |

*Example: Retrieve all CNAME records*

/retreive all CNAME records/
$resolver->resolve('google.com', DNS_CNAME);

Installation

Using composer:

$ composer require redbox/dns

Installation trough archive download

If you download the package from a website (for example github.io or phpclasses.org or any other) you will need composer installed on your machine. The reason for this is that Redbox-dns comes without the require vendor directory which is required to run the package.

First of all if you don't have composer installed you can find it here follow the instructions and don't get intimidated in fact its really really easy to install.

In the this sample i will assume you have composer installed (on any machine). Go to the package root (where composer.json is located) and execute the following command.

$ composer install  --no-dev

Unit Testing

Redbox-dns comes with a suite of tests that you can run. The tests will be automaticaly run on trevis-ci.com and inspected on scrutinizer-ci.com.

Requirements

The following versions of PHP are supported by this version.

  • PHP 5.4
  • PHP 5.5
  • PHP 5.6
  • PHP 7.0
  • PHP 7.1
  • HHVM

License

Redbox-dns is released under the MIT public license.

LICENSE

Author

This package is created and maintained by Johnny Mast. If you have any questions feel free to contact me on twitter by using @mastjohnny in your tweet.

Enjoy

Oh and if you've come down this far, you might as well follow me on twitter.

  Files folder image Files  
File Role Description
Files folder imageexamples (3 files)
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file allrecords.php Example Example script
  Accessible without login Plain text file autoload.php Aux. Auxiliary script
  Accessible without login Plain text file mxrecords.php Example Example script

  Files folder image Files  /  src  
File Role Description
  Plain text file Resolver.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file ResolverTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:171
This week:11
All time:8,229
This week:60Up