@@ -13,18 +13,39 @@ as [Streams](https://github.com/reactphp/stream).
1313
1414** Table of contents**
1515
16+ * [ Quickstart example] ( #quickstart-example )
1617* [ Processes] ( #processes )
1718 * [ EventEmitter Events] ( #eventemitter-events )
1819 * [ Methods] ( #methods )
1920 * [ Stream Properties] ( #stream-properties )
20- * [ Usage] ( #usage )
2121 * [ Prepending Commands with ` exec ` ] ( #prepending-commands-with-exec )
2222 * [ Sigchild Compatibility] ( #sigchild-compatibility )
2323 * [ Command Chaining] ( #command-chaining )
2424* [ Install] ( #install )
2525* [ Tests] ( #tests )
2626* [ License] ( #license )
2727
28+ ## Quickstart example
29+
30+ ``` php
31+ $loop = React\EventLoop\Factory::create();
32+
33+ $process = new React\ChildProcess\Process('echo foo');
34+ $process->start($loop);
35+
36+ $process->stdout->on('data', function ($chunk) {
37+ echo $chunk;
38+ });
39+
40+ $process->on('exit', function($exitCode, $termSignal) {
41+ echo 'Process exited with code ' . $exitCode . PHP_EOL;
42+ });
43+
44+ $loop->run();
45+ ```
46+
47+ See also the [ examples] ( examples ) .
48+
2849## Processes
2950
3051### EventEmitter Events
@@ -81,26 +102,6 @@ $process->stdin->close();
81102For more details, see the
82103[ ` DuplexStreamInterface ` ] ( https://github.com/reactphp/stream#duplexstreaminterface ) .
83104
84- ## Usage
85- ``` php
86- $loop = React\EventLoop\Factory::create();
87-
88- $process = new React\ChildProcess\Process('echo foo');
89-
90- $process->on('exit', function($exitCode, $termSignal) {
91- // ...
92- });
93-
94- $loop->addTimer(0.001, function($timer) use ($process) {
95- $process->start($timer->getLoop());
96-
97- $process->stdout->on('data', function($output) {
98- // ...
99- });
100- });
101-
102- $loop->run();
103- ```
104105### Prepending Commands with ` exec `
105106
106107Symfony pull request [ #5759 ] ( https://github.com/symfony/symfony/issues/5759 )
0 commit comments