New in Symfony 4.4: Better Control of Console Progress Bars
The most difficult thing when creating some progress bars is how to define their
redraw frequency with the
setRedrawFrequency() method. If you redraw it too
often, the progress bar flickers too much but if you redraw it not too often,
the progress bar looks unresponsive.
An additional problem is that sometimes you don't know how fast or slow will the command progress (e.g. when downloading some file, copying files, etc.).
In Symfony 4.4 we've improved the Symfony Console progress bars with two new methods which will help you control the redraw frequency:
1 2 3 4 5 6 7 8
use Symfony\Component\Console\Helper\ProgressBar; $progressBar = new ProgressBar($output, 50000); $progressBar->start(); $progressBar->setRedrawFrequency(100); $progressBar->minSecondsBetweenRedraws(0.1); $progressBar->maxSecondsBetweenRedraws(0.5);
methods will give you a greater control of the progress bar redraw frequency and
will ensure that you don't redraw it either too much or too little.
Related to this, in Symfony 4.4 we've also set
0.1 as the value of the
minSecondsBetweenRedraws property, so progress bars are not updated more
than 10 times per second by default (see Pull Request #32424).
New in Symfony 4.4: Better Control of Console Progress Bars symfony.com/index.php/blog/new-in-symfony-4-4-better-control-of-console-progress-barsTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.