How can I display Exception trace in laravel console command?
I found reason why -v is ignored:
in Illuminate/Foundation/Bootstrap/HandleExceptions.php
, the renderForConsole
method instantiates a ConsoleOutput
object, with default settings, not taking into account the verbosity settings the user asked for:
protected function renderForConsole($e)
{
$this->getExceptionHandler()->renderForConsole(new ConsoleOutput, $e);
}
For this reason, whatever -v -vv or -vvv is set, the $output->getVerbosity()
in vendor/symfony/console/Application.php
is always lower than OutputInterface::VERBOSITY_VERBOSE
, for that reason, the stack trace is not printed.
I probably start an issue on github for this, because I think it's much more convenient if errors are shown in CLI if user sets -v.
You can set the verbosity to whatever level you'd like by adding the following use statement:
use Symfony\Component\Console\Output\OutputInterface;
And then adding this to the top of your handle function:
$this->output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
See the documentation for symfony console here http://symfony.com/doc/current/console/verbosity.html for more information.