From 2bce8a1dbf0f7fbe175ac9a3297774ce698a4cc0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 5 Sep 2014 12:05:09 +0200 Subject: [PATCH] [Components][Process] `mustRun()` documentation --- components/process.rst | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/components/process.rst b/components/process.rst index a2d8dc67e4d..8a36b86ad7c 100644 --- a/components/process.rst +++ b/components/process.rst @@ -50,6 +50,25 @@ the contents of the output and :method:`Symfony\\Component\\Process\\Process::clearErrorOutput` clears the contents of the error output. +.. versionadded:: 2.5 + The ``mustRun()`` method was introduced in Symfony 2.5. + +With Symfony 2.5, you can use the :method:`Symfony\\Component\\Process\\Process::mustRun` +method which throws a :class:`Symfony\\Component\\Process\\Exception\\ProcessFailedException` +when the process couldn't be executed successfully:: + + use Symfony\Component\Process\Exception\ProcessFailedException; + use Symfony\Component\Process\Process; + + $process = new Process('ls -lsa'); + + try { + $process->mustRun(); + print $process->getOutput(); + } catch (ProcessFailedException $e) { + print $process->getErrorOutput(); + } + Getting real-time Process Output -------------------------------- @@ -218,17 +237,17 @@ Process Idle Timeout .. versionadded:: 2.4 The :method:`Symfony\\Component\\Process\\Process::setIdleTimeout` method was introduced in Symfony 2.4. - + In contrast to the timeout of the previous paragraph, the idle timeout only considers the time since the last output was produced by the process:: use Symfony\Component\Process\Process; - + $process = new Process('something-with-variable-runtime'); $process->setTimeout(3600); $process->setIdleTimeout(60); $process->run(); - + In the case above, a process is considered timed out, when either the total runtime exceeds 3600 seconds, or the process does not produce any output for 60 seconds.