Skip to content

[Console] Documented the setMaxSteps() method #9471

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
17 changes: 14 additions & 3 deletions components/console/helpers/progressbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,20 @@ you can also set the current progress by calling the
accordingly. By default, when using a ``max``, the redraw frequency
is set to *10%* of your ``max``.

If you don't know the number of steps in advance, just omit the steps argument
when creating the :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
instance::
If you don't know the exact number of steps in advance, set it to a reasonable
value and then call the ``setMaxSteps()`` method to update it as needed::

// start with a 50 units progressbar
$progressBar = new ProgressBar($output, 50);

// a complex task has just been created: increase the progressbar to 200 units
$progressBar->setMaxSteps(200);

.. versionadded:: 4.1
The ``setMaxSteps()`` method was introduced in Symfony 4.1.

Another solution is to just omit the steps argument when creating the
:class:`Symfony\\Component\\Console\\Helper\\ProgressBar` instance::

$progressBar = new ProgressBar($output);

Expand Down