Skip to content

Commit 39054c0

Browse files
committed
Update example to new eventloop API
1 parent c4ca735 commit 39054c0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ Once [installed](#install), you can use the following code to decorate a demo
1515
function and avoid sending unneeded HTTP requests:
1616

1717
```php
18-
$browser = new React\Http\Browser($loop);
18+
<?php
19+
20+
require __DIR__ . '/vendor/autoload.php';
21+
22+
$browser = new React\Http\Browser();
1923

2024
$fetch = function (int $id) use ($browser) {
21-
return $browser->get('http://httpbingo.org/status/' . $id)->then(function (ResponseInterface $response) {
25+
return $browser->get(
26+
'http://httpbingo.org/status/' . $id
27+
)->then(function (Psr\Http\Message\ResponseInterface $response) {
2228
return $response->getStatusCode();
29+
}, function (Exception $e) {
30+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
2331
});
2432
}
2533

0 commit comments

Comments
 (0)