8000 [RFC] Improving the new command console styling · Issue #16000 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[RFC] Improving the new command console styling #16000
Closed
@javiereguiluz

Description

@javiereguiluz

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('...');

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0