Search code examples
phpprogress-barcomposer-phpsymfony-console

Symfony console ProgressBar component is not displayed in composer scripts


Using the ProgressBar component in a command called by a composer script has no effect as the ProgressBar output is not shown.

Why is this? Is there a way to enforce its rendering?


Update: Now (since upgrade to symfony 2.6) it is shown, but the console refresh doesn't work correctly and for each update is adds a new line...


Solution

  • Make sure that you're using a up-to-date version of the component. Check if the bar works correct with the following snippet:

    <?php
    $max=10;
    $progress = new ProgressBar($output, $max);
    $progress->start();
    
    for ($i = 0; $i <= $max; ++$i) {
     sleep(1);
     $progress->advance();
    }
    $progress->finish();
    

    If this is the case, the task you execute between every $progress->advance(); step seems to write something to output which makes the bar be redrawn on every step.