Is there a way to detect what verbosity level the user has specified when creating a custom artisan command? I don't see anything about it in the docs.
To call another Artisan command and save its output you should use $this->call() from your command.
Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application.
php artisan optimize creates a compiled file of commonly used classes in other to reduce the amount of files that must be included on each request. After running the command, all commonly used classes are compiled and then saved to this file directory: bootstrap/cache/compiled.
There's the getVerbosity()
function in Symfony\Component\Console\Output\OutputInterface
and you can use $this->getOutput()
to retrieve the output object.
$verbosityLevel = $this->getOutput()->getVerbosity();
You then can compare the level to the constants defined inside OutputInterface
. For example:
if($verbosityLevel >= OutputInterface::VERBOSITY_VERBOSE){
// show verbose messages
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With