carlosafonso / php-dns-client
A DNS client written purely in PHP
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/carlosafonso/php-dns-client
Requires
- php: ~7.2
Requires (Dev)
- phpunit/phpunit: >=8.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2025-09-22 09:19:33 UTC
README
A DNS client library purely implemented in PHP, compatible with PHP 7.2+.
This is a work in progress. These are the Resource Record types currently understood by the library:
- A
- AAAA
- CNAME
- NS
- SRV
- MX
- SOA
- PTR
Processing responses with other types of Resource Records currently will result in an exception.
Install
Via Composer:
$ composer require carlosafonso/php-dns-client
Usage
The Client
class it the main entry point to consume the library. Client
instances allow to send Request
objects to a name server for resolution using the query()
method:
require __DIR__ . '/vendor/autoload.php'; $client = new Afonso\Dns\Client(); // Let's make an A request for example.com $request = new Afonso\Dns\Request('google.com', Afonso\Dns\ResourceRecord::TYPE_A); // Let's send it to name server 8.8.8.8 $response = $client->query($request, '8.8.8.8'); $response->getResourceRecords()[0]; // Instance of AResourceRecord $response->getResourceRecords()[0]->__toString(); // "216.58.211.238"
Security
If you discover any security related issues, please email the author directly instead of using the issue tracker.