Skip to content

Commit 4083d63

Browse files
committed
[Components][Process] mustRun() documentation
1 parent 4a7f973 commit 4083d63

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

components/process.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ the contents of the output and
5050
:method:`Symfony\\Component\\Process\\Process::clearErrorOutput` clears
5151
the contents of the error output.
5252

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+
5372
Getting real-time Process Output
5473
--------------------------------
5574

@@ -218,17 +237,17 @@ Process Idle Timeout
218237
.. versionadded:: 2.4
219238
The :method:`Symfony\\Component\\Process\\Process::setIdleTimeout` method
220239
was introduced in Symfony 2.4.
221-
240+
222241
In contrast to the timeout of the previous paragraph, the idle timeout only
223242
considers the time since the last output was produced by the process::
224243

225244
use Symfony\Component\Process\Process;
226-
245+
227246
$process = new Process('something-with-variable-runtime');
228247
$process->setTimeout(3600);
229248
$process->setIdleTimeout(60);
230249
$process->run();
231-
250+
232251
In the case above, a process is considered timed out, when either the total runtime
233252
exceeds 3600 seconds, or the process does not produce any output for 60 seconds.
234253

0 commit comments

Comments
 (0)