Progress helper enhancements¶
The console progress helper was added in 2.2. For 2.3, several enhancements were made to the display like avoiding too much flickering, or supporting UTF-8.
There is also one new feature, the possibility to set the current progress of the bar. That's interesting for instance when you are displaying the progress of a file download, where a callback provides the current download progress:
1 2 3 4 5
// advance the progress bar 1 unit $progress->advance(); // set the progress bar manually $progress->setCurrent(75);
A lot of people were asking for a way to nicely display a table from the console. That's now possible in Symfony 2.3:
1 2 3 4 5 6 7 8 9 10 11
$table = $app->getHelperSet()->get('table'); $table ->setHeaders(array('ISBN', 'Title', 'Author')) ->setRows(array( array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), )) ; $table->render($output);
And here is how it would be displayed:
I won't detail all the possible options as there is a nice cookbook entry for this feature.
Console output in more Formats¶
Did you know that you can get the help for any given command in the XML format? It has been possible since symfony 1, and it is heavily used by many IDEs as a mean to wrap the Symfony CLI tool in a nice GUI.
As of Symfony 2.3, this feature has been abstracted so that you can now get the output in the Markdown, JSON, and XML format:
1 2 3
$ php app/console help some:command --format=json $ php app/console list --format=json
More Verbosity Levels¶
Some commands gives you a more verbose output when using the
-v). You can also remove all the output of a command by using the
--quiet flag (or
As of 2.3, you now have access to three levels of verbosity:
1 2 3
$ php app/console foo --verbose=1 # equivalent to -v $ php app/console foo --verbose=2 # equivalent to -vv $ php app/console foo --verbose=3 # equivalent to -vvv
Composer already takes advantage of this feature. Upgrade to the latest
version of Composer, and try using
-vv when running
install; you will see that Composer outputs interesting information that can
help you debug problems.