1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00
Go to file
2019-06-13 19:52:24 +02:00
docs Update docs after Rfc1035StubResolver renaming 2019-03-13 17:38:40 +01:00
examples Fix benchmark example (#85) 2019-06-13 18:37:30 +02:00
lib Make required changes 2019-06-13 19:52:24 +02:00
test Fix import order and rename test 2019-03-13 17:43:10 +01:00
.editorconfig Switch to a new API to enable getting not only the first entry and not only A/AAAA records 2015-09-08 17:27:33 +02:00
.gitattributes Ignore docs/asset on export 2018-05-16 22:23:07 +02:00
.gitignore Add config test 2017-06-22 23:39:13 +02:00
.gitmodules Update to new shared docs repo 2017-09-27 14:49:02 +02:00
.php_cs.dist Use shared styles 2019-01-24 19:27:47 -06:00
.travis.yml Update Travis for CS fixer 2019-01-24 22:12:31 -06:00
appveyor.yml Move AppVeyor to PHP 7.3 2019-03-12 20:42:11 +01:00
composer.json Add composer scripts 2019-03-03 09:05:43 -06:00
CONTRIBUTING.md Massive refactor using amp/1.0.0 2015-08-01 22:38:25 -04:00
LICENSE Update LICENSE date 2017-06-24 08:14:50 +02:00
Makefile Update to PHPUnit 6, update code style 2017-06-17 10:49:54 +02:00
phpunit.xml.dist Update to PHPUnit 6, update code style 2017-06-17 10:49:54 +02:00
README.md Improve README example 2019-03-13 17:34:18 +01:00

dns

Build Status CoverageStatus License

amphp/dns provides asynchronous DNS name resolution for Amp.

Installation

composer require amphp/dns

Example

<?php

require __DIR__ . '/examples/_bootstrap.php';

use Amp\Dns;
use Amp\Loop;

Loop::run(function () {
    $githubIpv4 = yield Dns\resolve("github.com", Dns\Record::A);
    pretty_print_records("github.com", $githubIpv4);

    $googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
    $googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);

    $firstGoogleResult = yield Amp\Promise\first([$googleIpv4, $googleIpv6]);
    pretty_print_records("google.com", $firstGoogleResult);

    $combinedGoogleResult = yield Amp\Dns\resolve("google.com");
    pretty_print_records("google.com", $combinedGoogleResult);

    $googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
    pretty_print_records("google.com", $googleMx);
});