Skip to content

Commit 86c7f0e

Browse files
committed
Update example to new eventloop API and new TSV API
1 parent e233982 commit 86c7f0e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ Dave 1995-01-01 3.1.1.1
1818
Once [installed](#install), you can use the following code to read a TSV stream from `STDIN`:
1919

2020
```php
21-
$stdin = new React\Stream\ReadableResourceStream(STDIN, $loop);
22-
$stream = new Clue\React\Tsv\Decoder($stdin);
21+
<?php
22+
23+
require __DIR__ . '/vendor/autoload.php';
24+
25+
$stdin = new React\Stream\ReadableResourceStream(STDIN);
26+
$stream = new Clue\React\Tsv\TsvDecoder($stdin);
2327

2428
$stream->on('data', function ($data) {
2529
echo 'Name ' . $data['name'] . '\'s birthday is ' . $data['birthday'] . PHP_EOL;
2630
});
31+
32+
$stream->on('error', function (Exception $e) {
33+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
34+
});
2735
```
2836

2937
You can now process this example by running this on the command line:
@@ -32,7 +40,7 @@ You can now process this example by running this on the command line:
3240
$ php birthdays.php < users.tsv
3341
Alice's birthday is 2017-01-01
3442
Carol's birthday is 2006-01-01
35-
Dave's birthday is 1995-01-01 3.1.1.1
43+
Dave's birthday is 1995-01-01
3644
```
3745
3846
## Install

0 commit comments

Comments
 (0)