8000 [Process] Add doc for Process::disableOutput and Process::enableOutput · symfony/symfony-docs@4dde2ca · GitHub
[go: up one dir, main page]

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 4dde2ca

Browse files
committed
[Process] Add doc for Process::disableOutput and Process::enableOutput
1 parent 876a55d commit 4dde2ca

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

components/process.rst

Lines changed: 28 additions & 0 deletions
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)
0