Skip to content

Commit 8cab698

Browse files
committed
Improve documentation
1 parent 63fad80 commit 8cab698

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@ as defined in [RFC 6763](https://tools.ietf.org/html/rfc6763).
3434
Once [installed](#install), you can use the following code to look up the address of a local domain name:
3535

3636
```php
37+
<?php
38+
39+
require __DIR__ . '/vendor/autoload.php';
40+
3741
$factory = new Factory();
3842
$resolver = $factory->createResolver();
3943

4044
$resolver->lookup('hostname.local')->then(function ($ip) {
4145
echo 'Found: ' . $ip . PHP_EOL;
46+
}, function (Exception $e) {
47+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
4248
});
4349
```
4450

45-
See also the [examples](examples).
51+
See also the [examples](examples/).
4652

4753
## Usage
4854

@@ -83,6 +89,10 @@ Sending queries uses a [Promise](https://github.com/reactphp/promise)-based inte
8389
(i.e. either successfully resolved or rejected with an error):
8490

8591
```php
92+
<?php
93+
94+
require __DIR__ . '/vendor/autoload.php';
95+
8696
$resolver->lookup($hostname)->then(
8797
function ($ip) {
8898
// IP successfully resolved
@@ -105,6 +115,10 @@ you should look into also using [clue/reactphp-block](https://github.com/clue/re
105115
The resulting blocking code could look something like this:
106116

107117
```php
118+
<?php
119+
120+
require __DIR__ . '/vendor/autoload.php';
121+
108122
use Clue\React\Block;
109123

110124
$factory = new Factory();
@@ -123,6 +137,10 @@ try {
123137
Similarly, you can also process multiple lookups concurrently and await an array of results:
124138

125139
```php
140+
<?php
141+
142+
require __DIR__ . '/vendor/autoload.php';
143+
126144
$promises = array(
127145
$resolver->lookup('first.local'),
128146
$resolver->lookup('second.local'),

0 commit comments

Comments
 (0)