Skip to content

Documented the getIterator() method #7833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ for new output before going to the next iteration::
}
}

.. tip::

The Process component internally uses a PHP iterator to get the output while
it is generated. That iterator is exposed via the ``getIterator()`` method
to allow customizing its behavior::

$process = new Process('ls -lsa');
$process->start();
$iterator = $process->getIterator($process::ITER_SKIP_ERR | $process::ITER_KEEP_OUTPUT);
foreach ($iterator as $data) {
echo $data."\n";
}

.. versionadded:: 3.2
The ``getIterator()`` method was introduced in Symfony 3.2.

The ``mustRun()`` method is identical to ``run()``, except that it will throw
a :class:`Symfony\\Component\\Process\\Exception\\ProcessFailedException`
if the process couldn't be executed successfully (i.e. the process exited
Expand Down