1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00
dns/README.md

42 lines
1.2 KiB
Markdown
Raw Normal View History

2015-08-02 04:18:44 +02:00
# dns
2014-06-13 19:17:49 +02:00
2015-08-02 04:18:44 +02:00
[![Build Status](https://img.shields.io/travis/amphp/dns/master.svg?style=flat-square)](https://travis-ci.org/amphp/dns)
[![CoverageStatus](https://img.shields.io/coveralls/amphp/dns/master.svg?style=flat-square)](https://coveralls.io/github/amphp/dns?branch=master)
![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
`amphp/dns` provides asynchronous DNS name resolution for [Amp](https://github.com/amphp/amp).
## Installation
2014-09-23 22:47:55 +02:00
2015-08-02 04:18:44 +02:00
```bash
composer require amphp/dns
2014-09-24 16:51:48 +02:00
```
## Example
2014-09-24 16:51:48 +02:00
```php
<?php
2014-09-23 22:47:55 +02:00
2015-08-02 04:18:44 +02:00
require __DIR__ . '/vendor/autoload.php';
2014-09-23 22:47:55 +02:00
2017-07-06 21:22:39 +02:00
use Amp\Dns;
use Amp\Loop;
Loop::run(function () {
2017-07-06 21:22:39 +02:00
$githubIpv4 = yield Dns\resolve("github.com", Dns\Record::A);
2015-08-02 04:18:44 +02:00
var_dump($githubIpv4);
2014-09-23 22:47:55 +02:00
2017-07-06 21:22:39 +02:00
$googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
$googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);
2014-09-23 22:47:55 +02:00
2017-07-06 21:22:39 +02:00
$firstGoogleResult = yield Amp\Promise\first([$googleIpv4, $googleIpv6]);
2015-08-02 04:18:44 +02:00
var_dump($firstGoogleResult);
2015-09-18 15:09:28 +02:00
2017-07-06 21:22:39 +02:00
$combinedGoogleResult = yield Amp\Dns\resolve("google.com");
2015-09-18 15:09:28 +02:00
var_dump($combinedGoogleResult);
2017-07-06 21:22:39 +02:00
$googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
2015-09-18 15:09:28 +02:00
var_dump($googleMx);
2014-09-23 22:47:55 +02:00
});
```