@@ -34,15 +34,21 @@ as defined in [RFC 6763](https://tools.ietf.org/html/rfc6763).
34
34
Once [ installed] ( #install ) , you can use the following code to look up the address of a local domain name:
35
35
36
36
``` php
37
+ <?php
38
+
39
+ require __DIR__ . '/vendor/autoload.php';
40
+
37
41
$factory = new Factory();
38
42
$resolver = $factory->createResolver();
39
43
40
44
$resolver->lookup('hostname.local')->then(function ($ip) {
41
45
echo 'Found: ' . $ip . PHP_EOL;
46
+ }, function (Exception $e) {
47
+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
42
48
});
43
49
```
44
50
45
- See also the [ examples] ( examples ) .
51
+ See also the [ examples] ( examples/ ) .
46
52
47
53
## Usage
48
54
@@ -83,6 +89,10 @@ Sending queries uses a [Promise](https://github.com/reactphp/promise)-based inte
83
89
(i.e. either successfully resolved or rejected with an error):
84
90
85
91
``` php
92
+ <?php
93
+
94
+ require __DIR__ . '/vendor/autoload.php';
95
+
86
96
$resolver->lookup($hostname)->then(
87
97
function ($ip) {
88
98
// IP successfully resolved
@@ -105,6 +115,10 @@ you should look into also using [clue/reactphp-block](https://github.com/clue/re
105
115
The resulting blocking code could look something like this:
106
116
107
117
``` php
118
+ <?php
119
+
120
+ require __DIR__ . '/vendor/autoload.php';
121
+
108
122
use Clue\React\Block;
109
123
110
124
$factory = new Factory();
@@ -123,6 +137,10 @@ try {
123
137
Similarly, you can also process multiple lookups concurrently and await an array of results:
124
138
125
139
``` php
140
+ <?php
141
+
142
+ require __DIR__ . '/vendor/autoload.php';
143
+
126
144
$promises = array(
127
145
$resolver->lookup('first.local'),
128
146
$resolver->lookup('second.local'),
0 commit comments