Skip to content

Commit fc1576a

Browse files
committed
feature #3664 [Process] Add doc for Process::disableOutput and Process::enableOutput (romainneutron)
This PR was merged into the master branch. Discussion ---------- [Process] Add doc for Process::disableOutput and Process::enableOutput | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes symfony/symfony#10425 | Applies to | 2.5 Hello, this is the doc related to the PR :) Commits ------- 4dde2ca [Process] Add doc for Process::disableOutput and Process::enableOutput
2 parents 3731e2e + 4dde2ca commit fc1576a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

components/process.rst

+28
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,34 @@ You can access the `pid`_ of a running process with the
281281
you may have to prefix your commands with `exec`_. Please read
282282
`Symfony Issue#5759`_ to understand why this is happening.
283283

284+
Disabling Output
285+
----------------
286+
287+
.. versionadded:: 2.5
288+
The :method:`Symfony\\Component\\Process\\Process::disableOutput` and
289+
:method:`Symfony\\Component\\Process\\Process::enableOutput` methods were
290+
introduced in Symfony 2.5.
291+
292+
As standard output and error output are always fetched from the underlying process,
293+
it might be convenient to disable output in some cases to save memory.
294+
Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
295+
:method:`Symfony\\Component\\Process\\Process::enableOutput` to toggle this feature::
296+
297+
use Symfony\Component\Process\Process;
298+
299+
$process = new Process('/usr/bin/php worker.php');
300+
$process->disableOutput();
301+
$process->run();
302+
303+
.. caution::
304+
305+
You can not enable or disable the output while the process is running.
306+
307+
If you disable the output, you cannot access ``getOutput``,
308+
``getIncrementalOutput``, ``getErrorOutput`` or ``getIncrementalErrorOutput``.
309+
Moreover, you could not pass a callback to the ``start``, ``run`` or ``mustRun``
310+
methods or use ``setIdleTimeout``.
311+
284312
.. _`Symfony Issue#5759`: https://github.com/symfony/symfony/issues/5759
285313
.. _`PHP Bug#39992`: https://bugs.php.net/bug.php?id=39992
286314
.. _`exec`: http://en.wikipedia.org/wiki/Exec_(operating_system)

0 commit comments

Comments
 (0)