Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eeaddb3

Browse filesBrowse files
xabbuhChristian Flothmann
authored andcommitted
[Components][Process] mustRun() documentation
1 parent 4a7f973 commit eeaddb3
Copy full SHA for eeaddb3

File tree

Expand file treeCollapse file tree

1 file changed

+24
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-4
lines changed

‎components/process.rst

Copy file name to clipboardExpand all lines: components/process.rst
+24-4Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ a command in a sub-process::
3131
throw new \RuntimeException($process->getErrorOutput());
3232
}
3333

34-
print $process->getOutput();
34+
echo $process->getOutput();
3535

3636
The component takes care of the subtle differences between the different platforms
3737
when executing the command.
@@ -50,6 +50,26 @@ 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+
68+
echo $process->getOutput();
69+
} catch (ProcessFailedException $e) {
70+
echo $e->getMessage();
71+
}
72+
5373
Getting real-time Process Output
5474
--------------------------------
5575

@@ -218,17 +238,17 @@ Process Idle Timeout
218238
.. versionadded:: 2.4
219239
The :method:`Symfony\\Component\\Process\\Process::setIdleTimeout` method
220240
was introduced in Symfony 2.4.
221-
241+
222242
In contrast to the timeout of the previous paragraph, the idle timeout only
223243
considers the time since the last output was produced by the process::
224244

225245
use Symfony\Component\Process\Process;
226-
246+
227247
$process = new Process('something-with-variable-runtime');
228248
$process->setTimeout(3600);
229249
$process->setIdleTimeout(60);
230250
$process->run();
231-
251+
232252
In the case above, a process is considered timed out, when either the total runtime
233253
exceeds 3600 seconds, or the process does not produce any output for 60 seconds.
234254

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.