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 1b77af8

Browse filesBrowse files
committed
minor #10949 [Console] Add documentation for the ProgressBar::iterate method (jvasseur)
This PR was merged into the master branch. Discussion ---------- [Console] Add documentation for the ProgressBar::iterate method Doc PR for symfony/symfony#29753 Commits ------- 5c0b716 [Console] Add documentation for the ProgressBar::iterate method
2 parents c246ddc + 5c0b716 commit 1b77af8
Copy full SHA for 1b77af8

File tree

1 file changed

+17
-0
lines changed
Filter options

1 file changed

+17
-0
lines changed

‎components/console/helpers/progressbar.rst

Copy file name to clipboardExpand all lines: components/console/helpers/progressbar.rst
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ that the progress bar display is refreshed with a 100% completion.
9595
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::display`
9696
to show the progress bar again.
9797

98+
If you want to use the progress bar to show the progress of an iteration you can use the
99+
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::iterate` method that will automatically call ``start``,
100+
``advance`` and ``finish`` while iterating::
101+
102+
use Symfony\Component\Console\Helper\ProgressBar;
103+
104+
$progressBar = new ProgressBar($output);
105+
106+
// starts and displays the progress bar
107+
foreach ($progressBar->iterate($iterable) as $key => $value) {
108+
// ... do some work
109+
}
110+
111+
.. versionadded:: 4.3
112+
113+
The ``iterate`` method was introduced in Symfony 4.3.
114+
98115
Customizing the Progress Bar
99116
----------------------------
100117

0 commit comments

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