Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.

Formatter Helper

Formatter Helper

The Formatter helper provides functions to format the output with colors. You can do more advanced things with this helper than you can in How to Color and Style the Console Output.

The Symfony\Component\Console\Helper\FormatterHelper is included in the default helper set, which you can get by calling getHelperSet():

$formatter = $this->getHelper('formatter');

The methods return a string, which you’ll usually render to the console by passing it to the OutputInterface::writeln method.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.