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 c84cb10

Browse filesBrowse files
javiereguiluzxabbuh
authored andcommitted
Documented the getIterator() method
1 parent af876eb commit c84cb10
Copy full SHA for c84cb10

File tree

Expand file treeCollapse file tree

1 file changed

+16
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-0
lines changed

‎components/process.rst

Copy file name to clipboardExpand all lines: components/process.rst
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ for new output before going to the next iteration::
6969
}
7070
}
7171

72+
.. tip::
73+
74+
The Process component internally uses a PHP iterator to get the output while
75+
it is generated. That iterator is exposed via the ``getIterator()`` method
76+
to allow customizing its behavior::
77+
78+
$process = new Process('ls -lsa');
79+
$process->start();
80+
$iterator = $process->getIterator($process::ITER_SKIP_ERR | $process::ITER_KEEP_OUTPUT);
81+
foreach ($iterator as $data) {
82+
echo $data."\n";
83+
}
84+
85+
.. versionadded:: 3.2
86+
The ``getIterator()`` method was introduced in Symfony 3.2.
87+
7288
The ``mustRun()`` method is identical to ``run()``, except that it will throw
7389
a :class:`Symfony\\Component\\Process\\Exception\\ProcessFailedException`
7490
if the process couldn't be executed successfully (i.e. the process exited

0 commit comments

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