use Symfony\Component\Console\Output\OutputInterface; function outputString(OutputInterface $output, $message) { if ($output->isDebug()) { $output->writeln("DEBUG: " . $message); } else { $output->writeln($message); } }
use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableStyle; use Symfony\Component\Console\Output\OutputInterface; function outputTable(OutputInterface $output, $data) { $table = new Table($output); $table->setHeaders(array('Name', 'Age', 'Email')); // Add data to the table foreach ($data as $row) { $table->addRow($row); } // Customize the table style $style = new TableStyle(); $style->setHorizontalBorderChar('-'); $style->setVerticalBorderChar('|'); $style->setCrossingChar('+'); $table->setStyle($style); // Render the table to the console $table->render(); }In this example, the outputTable function takes an instance of OutputInterface as its first parameter, along with an array of data to display in a table. The function uses the Table and TableStyle classes to create a formatted table with custom borders and separators. Finally, the table is output to the console using the render method. Overall, OutputInterface is a powerful class in the Symfony\Component\Console\Output package library that can help developers customize console output and provide more detailed information when necessary.