How to use Symfony2's built-in verbose command line parameter to control verbosity in your commands.
Let's say you want a lot of detail when you run a command manually in order to debug or even to see what is happening. But you don't want so much detail in other situations, for the same command. For instance:
Symfony2's command component has a built-in verbose option for command
that you can find with
$ app/console list Symfony version 2.0.0 - app/dev/debug Usage: [options] command [arguments] Options: ... --verbose -v Increase verbosity of messages. ...
In your command, just check if the option
verbose is given by the user
with no need declare it in
So you can call your command with the verbose option:
app/console acme:mycommand --verbose
Or even with the shortcut given by Symfony2:
app/console acme:mycommand -v