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

46 lines
1.4 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)
![Unstable](https://img.shields.io/badge/api-unstable-orange.svg?style=flat-square)
![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
2015-08-02 04:18:44 +02:00
`amphp/dns` provides asynchronous DNS name resolution based on the [`amp`](https://github.com/amphp/amp)
concurrency framework.
2015-08-02 04:18:44 +02:00
**Required PHP Version**
2015-08-02 04:18:44 +02:00
- PHP 5.5+
2015-08-02 04:18:44 +02:00
**Installation**
2014-09-23 22:47:55 +02:00
2015-08-02 04:18:44 +02:00
```bash
$ composer require amphp/dns:dev-master
2014-09-24 16:51:48 +02:00
```
2015-08-02 04:18:44 +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
2015-08-02 04:18:44 +02:00
Amp\run(function () {
2015-09-18 15:09:28 +02:00
$githubIpv4 = (yield Amp\Dns\resolve("github.com", $options = ["types" => Amp\Dns\Record::A]));
2015-08-02 04:18:44 +02:00
var_dump($githubIpv4);
2014-09-23 22:47:55 +02:00
2015-09-18 15:09:28 +02:00
$googleIpv4 = Amp\Dns\resolve("google.com", $options = ["types" => Amp\Dns\Record::A]);
$googleIpv6 = Amp\Dns\resolve("google.com", $options = ["types" => Amp\Dns\Record::AAAA]);
2014-09-23 22:47:55 +02:00
2015-08-02 04:18:44 +02:00
$firstGoogleResult = (yield Amp\first([$ipv4Result, $ipv6Result]));
var_dump($firstGoogleResult);
2015-09-18 15:09:28 +02:00
$combinedGoogleResult = (yield Amp\Dns\resolve("google.com"));
var_dump($combinedGoogleResult);
2016-07-07 11:08:00 +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
});
```