mirror of
https://github.com/danog/dns.git
synced 2024-11-26 20:14:51 +01:00
bd86e80712
We've been trying to avoid such generic names in other libraries. |
||
---|---|---|
.github/workflows | ||
docs | ||
examples | ||
src | ||
test | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
.php-cs-fixer.dist.php | ||
composer-require-check.json | ||
composer.json | ||
CONTRIBUTING.md | ||
LICENSE | ||
phpunit.xml.dist | ||
psalm.xml | ||
README.md |
dns
amphp/dns
provides asynchronous DNS resolution for PHP based on Amp.
Installation
composer require amphp/dns
Example
<?php
require __DIR__ . '/examples/_bootstrap.php';
$githubIpv4 = Amp\Dns\resolve("github.com", Dns\Record::A);
pretty_print_records("github.com", $githubIpv4);
$firstGoogleResult = Amp\Future\awaitFirst([
Amp\async(fn() => Amp\Dns\resolve("google.com", Dns\Record::A)),
Amp\async(fn() => Amp\Dns\resolve("google.com", Dns\Record::AAAA)),
]);
pretty_print_records("google.com", $firstGoogleResult);
$combinedGoogleResult = Amp\Dns\resolve("google.com");
pretty_print_records("google.com", $combinedGoogleResult);
$googleMx = Amp\Dns\query("google.com", Amp\Dns\Record::MX);
pretty_print_records("google.com", $googleMx);