PHP code example of danog / libdns-native
1. Go to this page and download the library: Download danog/libdns-native 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/ */
danog / libdns-native example snippets
anog\LibDNSNative\NativeEncoderFactory;
use danog\LibDNSNative\NativeDecoderFactory;
use LibDNS\Records\QuestionFactory;
use LibDNS\Records\ResourceQTypes;
use LibDNS\Messages\MessageFactory;
use LibDNS\Messages\MessageTypes;
$question = (new QuestionFactory)->create(ResourceQTypes::DNSKEY);
$question->setName('daniil.it');
$message = (new MessageFactory)->create(MessageTypes::QUERY);
$records = $message->getQuestionRecords();
$records->add($question);
$encoder = (new NativeEncoderFactory)->create();
$question = $encoder->encode($message);
$result = dns_get_record(...$question);
$decoder = (new NativeDecoderFactory)->create();
$result = $decoder->decode($result, ...$question);