File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,12 +18,20 @@ Dave 1995-01-01 3.1.1.1
1818Once [ 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
2937You 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
3341Alice' s birthday is 2017-01-01
3442Carol' 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
You can’t perform that action at this time.
0 commit comments