arrayaccess / dns-client
Php DNS Client Resolver
Fund package maintenance!
arrayiterator
Liberapay
Patreon
www.paypal.me/pentagonal
Requires
- php: >=8.1
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.4
- psr/cache: ^3
- slevomat/coding-standard: ^8.14
- squizlabs/php_codesniffer: 3.7.2
README
Native Php DNS Client / Resolver implementation of RFC 1035. Support PSR-6: Caching Interface.
Requirements
Php 8.1
or later- Function
focksopen
enabled & allowed outbound connection to port53
- Network Connectivity (Absolutely!)
Installing
Currently, in development:
composer require arrayaccess/dns-client
Usage
use ArrayAccess\DnsRecord\Cache\Adapter\Psr6CacheAdapter; use ArrayAccess\DnsRecord\DnsServerStorage; use ArrayAccess\DnsRecord\Resolver; $cache = new Psr6CacheAdapter(); // $cache->setCacheItemPool($cacheProvider); $dnsServer = DnsServerStorage::createDefault(); $resolver = new Resolver($dnsServer, $cache); /** * Lookup Single */ $useCache = true; // default to true $timeout = 3.5; // 3.5 seconds $response = $resolver->lookup('domain-name.ext', 'A', 'IN', $timeout, $useCache); /** * Enable Pseudo OPT */ $resolver->setDnsSec(true); $response = $resolver->lookup('domain-name.ext', 'A', 'IN'); $answers = $response->getAnswers(); $records = $answers->getRecords(); // Filter "A" Address Only $arrayA = $records->getFilteredType('A');
IXFR & AXFR aren't fully implemented yet
Note
The RRTypes not completed yet, will use RRDefault as default.