@@ -33,21 +33,17 @@ factory. All you need to give it is a nameserver, then you can start resolving
3333names, baby!
3434
3535``` php
36- $loop = React\EventLoop\Factory::create();
37-
3836$config = React\Dns\Config\Config::loadSystemConfigBlocking();
3937if (!$config->nameservers) {
4038 $config->nameservers[] = '8.8.8.8';
4139}
4240
4341$factory = new React\Dns\Resolver\Factory();
44- $dns = $factory->create($config, $loop );
42+ $dns = $factory->create($config);
4543
4644$dns->resolve('igor.io')->then(function ($ip) {
4745 echo "Host: $ip\n";
4846});
49-
50- $loop->run();
5147```
5248
5349See also the [ first example] ( examples ) .
@@ -72,15 +68,13 @@ But there's more.
7268You can cache results by configuring the resolver to use a ` CachedExecutor ` :
7369
7470``` php
75- $loop = React\EventLoop\Factory::create();
76-
7771$config = React\Dns\Config\Config::loadSystemConfigBlocking();
7872if (!$config->nameservers) {
7973 $config->nameservers[] = '8.8.8.8';
8074}
8175
8276$factory = new React\Dns\Resolver\Factory();
83- $dns = $factory->createCached($config, $loop );
77+ $dns = $factory->createCached($config);
8478
8579$dns->resolve('igor.io')->then(function ($ip) {
8680 echo "Host: $ip\n";
@@ -91,8 +85,6 @@ $dns->resolve('igor.io')->then(function ($ip) {
9185$dns->resolve('igor.io')->then(function ($ip) {
9286 echo "Host: $ip\n";
9387});
94-
95- $loop->run();
9688```
9789
9890If the first call returns before the second, only one query will be executed.
@@ -110,9 +102,8 @@ You can also specify a custom cache implementing [`CacheInterface`](https://gith
110102
111103``` php
112104$cache = new React\Cache\ArrayCache();
113- $loop = React\EventLoop\Factory::create();
114105$factory = new React\Dns\Resolver\Factory();
115- $dns = $factory->createCached('8.8.8.8', $loop , $cache);
106+ $dns = $factory->createCached('8.8.8.8', null , $cache);
116107```
117108
118109See also the wiki for possible [ cache implementations] ( https://github.com/reactphp/react/wiki/Users#cache-implementations ) .
@@ -215,8 +206,7 @@ For more advanced usages one can utilize this class directly.
215206The following example looks up the ` IPv6 ` address for ` igor.io ` .
216207
217208``` php
218- $loop = Factory::create();
219- $executor = new UdpTransportExecutor('8.8.8.8:53', $loop);
209+ $executor = new UdpTransportExecutor('8.8.8.8:53');
220210
221211$executor->query(
222212 new Query($name, Message::TYPE_AAAA, Message::CLASS_IN)
@@ -225,8 +215,6 @@ $executor->query(
225215 echo 'IPv6: ' . $answer->data . PHP_EOL;
226216 }
227217}, 'printf');
228-
229- $loop->run();
230218```
231219
232220See also the [ fourth example] ( examples ) .
@@ -236,9 +224,8 @@ want to use this in combination with a `TimeoutExecutor` like this:
236224
237225``` php
238226$executor = new TimeoutExecutor(
239- new UdpTransportExecutor($nameserver, $loop),
240- 3.0,
241- $loop
227+ new UdpTransportExecutor($nameserver),
228+ 3.0
242229);
243230```
244231
@@ -249,9 +236,8 @@ combination with a `RetryExecutor` like this:
249236``` php
250237$executor = new RetryExecutor(
251238 new TimeoutExecutor(
252- new UdpTransportExecutor($nameserver, $loop),
253- 3.0,
254- $loop
239+ new UdpTransportExecutor($nameserver),
240+ 3.0
255241 )
256242);
257243```
@@ -268,9 +254,8 @@ a `CoopExecutor` like this:
268254$executor = new CoopExecutor(
269255 new RetryExecutor(
270256 new TimeoutExecutor(
271- new UdpTransportExecutor($nameserver, $loop),
272- 3.0,
273- $loop
257+ new UdpTransportExecutor($nameserver),
258+ 3.0
274259 )
275260 )
276261);
@@ -293,8 +278,7 @@ For more advanced usages one can utilize this class directly.
293278The following example looks up the ` IPv6 ` address for ` reactphp.org ` .
294279
295280``` php
296- $loop = Factory::create();
297- $executor = new TcpTransportExecutor('8.8.8.8:53', $loop);
281+ $executor = new TcpTransportExecutor('8.8.8.8:53');
298282
299283$executor->query(
300284 new Query($name, Message::TYPE_AAAA, Message::CLASS_IN)
@@ -303,8 +287,6 @@ $executor->query(
303287 echo 'IPv6: ' . $answer->data . PHP_EOL;
304288 }
305289}, 'printf');
306-
307- $loop->run();
308290```
309291
310292See also [ example #92 ] ( examples ) .
@@ -314,9 +296,8 @@ want to use this in combination with a `TimeoutExecutor` like this:
314296
315297``` php
316298$executor = new TimeoutExecutor(
317- new TcpTransportExecutor($nameserver, $loop),
318- 3.0,
319- $loop
299+ new TcpTransportExecutor($nameserver),
300+ 3.0
320301);
321302```
322303
@@ -342,9 +323,8 @@ combination with a `CoopExecutor` like this:
342323``` php
343324$executor = new CoopExecutor(
344325 new TimeoutExecutor(
345- new TcpTransportExecutor($nameserver, $loop),
346- 3.0,
347- $loop
326+ new TcpTransportExecutor($nameserver),
327+ 3.0
348328 )
349329);
350330```
@@ -412,7 +392,7 @@ use this code:
412392``` php
413393$hosts = \React\Dns\Config\HostsFile::loadFromPathBlocking();
414394
415- $executor = new UdpTransportExecutor('8.8.8.8:53', $loop );
395+ $executor = new UdpTransportExecutor('8.8.8.8:53');
416396$executor = new HostsFileExecutor($hosts, $executor);
417397
418398$executor->query(
0 commit comments