I writing a module, actually a custom command in Magento 2. Magento 2 console application is proudly powered by Symfony Console, obviously. And my concernation is how to disable output from $output
for specified command?
For example:
$setupUpgradeCommand = $this->getApplication()->find('setup:upgrade');
$setupUpgradeArguments = array(
'command' => 'setup:upgrade',
'--quiet' => true,
);
$setupUpgradeInput = new ArrayInput($setupUpgradeArguments);
$start = microtime(true);
$output->writeln('<info>Start upgrading module schemas...</info>');
$setupUpgradeCommand->run($setupUpgradeInput, $output);
$output->writeln('...............................<info>OK</info>');
// My long logic-code start from here....
Unfortunately, even I set --quiet
to true, output of this command setup:upgrade
still there.
Any ideas?
As answered in a comment.. although almost exactly the same as the answer by @toooni.
You can insert the NullOutput
rather than inserting the actual output object supplied by the command.
use Symfony\Component\Console\Output\NullOutput;
$setupUpgradeCommand->run($setupUpgradeInput, new NullOutput());