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

Skip to content

Commit a6c5de8

Browse files
committed
feature #7833 Documented the getIterator() method (javiereguiluz)
This PR was squashed before being merged into the 3.2 branch (closes #7833). Discussion ---------- Documented the getIterator() method This fixes #7184. Commits ------- c84cb10 Documented the getIterator() method
2 parents 7dc3469 + c84cb10 commit a6c5de8

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