8000 Documented the getIterator() method · symfony/symfony-docs@c84cb10 · GitHub
[go: up one dir, main page]

Skip to content

Commit c84cb10

Browse files
javiereguiluzxabbuh
authored andcommitted
Documented the getIterator() method
1 parent af876eb commit c84cb10

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

components/process.rst

Lines 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