@@ -50,6 +50,25 @@ the contents of the output and
50
50
:method: `Symfony\\ Component\\ Process\\ Process::clearErrorOutput ` clears
51
51
the contents of the error output.
52
52
53
+ .. versionadded :: 2.5
54
+ The ``mustRun() `` method was introduced in Symfony 2.5.
55
+
56
+ With Symfony 2.5, you can use the :method: `Symfony\\ Component\\ Process\\ Process::mustRun `
57
+ method which throws a :class: `Symfony\\ Component\\ Process\\ Exception\\ ProcessFailedException `
58
+ when the process couldn't be executed successfully::
59
+
60
+ use Symfony\Component\Process\Exception\ProcessFailedException;
61
+ use Symfony\Component\Process\Process;
62
+
63
+ $process = new Process('ls -lsa');
64
+
65
+ try {
66
+ $process->mustRun();
67
+ print $process->getOutput();
68
+ } catch (ProcessFailedException $e) {
69
+ print $e->getMessage();
70
+ }
71
+
53
72
Getting real-time Process Output
54
73
--------------------------------
55
74
@@ -218,17 +237,17 @@ Process Idle Timeout
218
237
.. versionadded :: 2.4
219
238
The :method: `Symfony\\ Component\\ Process\\ Process::setIdleTimeout ` method
220
239
was introduced in Symfony 2.4.
221
-
240
+
222
241
In contrast to the timeout of the previous paragraph, the idle timeout only
223
242
considers the time since the last output was produced by the process::
224
243
225
244
use Symfony\Component\Process\Process;
226
-
245
+
227
246
$process = new Process('something-with-variable-runtime');
228
247
$process->setTimeout(3600);
229
248
$process->setIdleTimeout(60);
230
249
$process->run();
231
-
250
+
232
251
In the case above, a process is considered timed out, when either the total runtime
233
252
exceeds 3600 seconds, or the process does not produce any output for 60 seconds.
234
253
0 commit comments