1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00
Go to file
Aaron Piotrowski 7e78dd0c96
Merge branch 'master' into v2-revolt
# Conflicts:
#	lib/Rfc1035StubResolver.php
2021-09-14 19:23:21 -05:00
.github/workflows Switch from Travis CI to GitHub Actions 2021-02-02 20:44:44 +01:00
docs Update shared documentation files 2020-08-30 21:22:30 +02:00
examples Update examples 2020-11-09 10:47:03 -06:00
lib Merge branch 'master' into v2-revolt 2021-09-14 19:23:21 -05:00
test Use revolt 2021-03-27 10:08:32 +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 Improve warning if config loading fails 2021-02-02 20:38:19 +01: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
appveyor.yml Update AppVeyor to PHP 7.4 (#97) 2020-03-04 19:46:13 +01:00
composer.json Use revolt 2021-03-27 10:08:32 +01:00
CONTRIBUTING.md Massive refactor using amp/1.0.0 2015-08-01 22:38:25 -04:00
LICENSE Use revolt 2021-03-27 10:08:32 +01:00
Makefile Update to PHPUnit 6, update code style 2017-06-17 10:49:54 +02:00
phpunit.xml.dist Ignore ServFail / NxDomain for each list responses 2020-06-19 22:28:16 +02:00
README.md Change README to use new build badge 2021-02-02 21:01:04 +01:00

dns

Build Status License

amphp/dns provides asynchronous DNS resolution for PHP based on 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);
});