File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,24 @@ are done doing other stuff::
113
113
$process->start();
114
114
115
115
// ... do other things
116
+
117
+ $process->wait();
118
+
119
+ // ... do things after the process has finished
116
120
121
+ .. note ::
122
+
123
+ The :method: `Symfony\\ Component\\ Process\\ Process::wait ` method is blocking,
124
+ which means that your code will halt at this line until the external
125
+ process is completed.
126
+
127
+ :method: `Symfony\\ Component\\ Process\\ Process::wait ` takes one optional argument:
128
+ a callback that is called repeatedly whilst the process is still running, passing
129
+ in the output and its type::
130
+
131
+ $process = new Process('ls -lsa');
132
+ $process->start();
133
+
117
134
$process->wait(function ($type, $buffer) {
118
135
if (Process::ERR === $type) {
119
136
echo 'ERR > '.$buffer;
@@ -122,12 +139,6 @@ are done doing other stuff::
122
139
}
123
140
});
124
141
125
- .. note ::
126
-
127
- The :method: `Symfony\\ Component\\ Process\\ Process::wait ` method is blocking,
128
- which means that your code will halt at this line until the external
129
- process is completed.
130
-
131
142
Stopping a Process
132
143
------------------
133
144
You can’t perform that action at this time.
0 commit comments