Closed
Description
Problem
The new Symfony console styles requires us to do the following:
use Symfony\Component\Console\Style\SymfonyStyle;
// ...
protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output); // <-- this is the problem
$output->title('...');
$output->table('...');
// ...
}
Overriding the original $output
variable is a really bad practice, it introduces a lot of issues in some commands and it's ugly.
Solution
I want to change the new $output
variable by a new variable. Here are some suggestions. Please tell me which one you prefer or provide an alternative. Thanks!
$helper = new SymfonyStyle($input, $output);
$helper->title('...');
$helper->table('...');
// ...
$iohelper = new SymfonyStyle($input, $output);
$iohelper->title('...');
$iohelper->table('...');
// ...
$io = new SymfonyStyle($input, $output);
$io->title('...');
$io->table('...');
// ...
$formatter = new SymfonyStyle($input, $output);
$formatter->title('...');
$formatter->table('...');
// ...