use Symfony\Component\Console\Formatter\OutputFormatterStyle; // ... $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink')); $output->getFormatter()->setStyle('fire', $style); $output->writeln('<fire>foo</fire>');
Available foreground and background colors are: black, red, green, yellow, blue, magenta, cyan and white.
And available options are: bold, underscore, blink, reverse (enables the “reverse video” mode where the background and foreground colors are swapped) and conceal (sets the foreground color to transparent, making the typed text invisible – although it can be selected and copied; this option is commonly used when asking the user to type sensitive information).
// green text
$output->writeln('<info>foo</info>');
// yellow text
$output->writeln('<comment>foo</comment>');
// black text on a cyan background
$output->writeln('<question>foo</question>');
// white text on a red background
$output->writeln('<error>foo</error>');
// green text
$output->writeln('<fg=green>foo</>');
// black text on a cyan background
$output->writeln('<fg=black;bg=cyan>foo</>');
// bold text on a yellow background
$output->writeln('<bg=yellow;options=bold>foo</>');
// bold text with underscore
$output->writeln('<options=bold;underscore>foo</>');
