I'm writing a console app using Symfony Console Component. I'm trying to interact with questions and tables. I want to ask a question and then output a table and then ask another and output another table. All of that happens in the same command class. This is my code:
protected function interact( InputInterface $input, OutputInterface $output ) {
$this->input = $input;
$this->output = $output;
$question_helper = $this->getHelper( 'question' );
$question = ( new ConfirmationQuestion( 'This is a confirmation question:' ) );
$question_result = $question_helper->ask( $this->input, $this->output, $question );
$table = new Table( $this->output );
$table
->setHeaders( array( 'Name', 'Age' ) )
->setRows(
array(
array( 'Mike', 21 ),
array( 'Sara', 22 ),
)
);
$table->setStyle( 'box' );
$table->render();
}
When I'm trying to implement my code, the question works well but when I output the table it shows in a weird way like this:
This is a confirmation question: bla bla
┌──────┬─────└‚ Name │ Age │
├──────┼─────┤
│ Mike │ 21 │
│ Sara │ 22 │
└──────┴─────┘
If I echo the table before the question it works:
┌──────┬─────┐
│ Name │ Age │
├──────┼─────┤
│ Mike │ 21 │
│ Sara │ 22 │
└──────┴─────┘
This is a confirmation question: bla bla
Any one has any clue how I can solve this?