New in Symfony 7.2: Silent Verbosity

Contributed by
Wouter de Jong
in
#53632

When working with certain third-party services, you may need your Symfony
application to produce logs in JSON format for easier integration. Fortunately,
this is straightforward to achieve with Symfony’s Monolog integration.

However, when running some console commands, they might generate output on both
the stdout and stderr streams. This is problematic if the third-party
service expects only JSON log contents and encounters this unstructured data.

Thankfully, Symfony provides a feature to control the verbosity of console commands.
Add the -q or –quiet option to your command (or set the SHELL_VERBOSITY
env var to -1) and you won’t get any output when running the command.

The only things not suppressed by the quiet verbosity are errors and exceptions.
To address this, in Symfony 7.2 we’re introducing a new verbosity level called
silent (equivalent to the SHELL_VERBOSITY=-2 env var). This new level
suppresses all output, including errors and exceptions:

# suppresses all output
$ php bin/console some-command –silent

# suppresses all output except errors
$ php bin/console some-command –quiet

Sponsor the Symfony project.

Symfony Blog

Read More

Latest News

PHP-Releases

PHP 8.4.1 released!

PHP 8.1.31 released!

PHP 8.3.14 released!

PHP 8.2.26 released!

Generated by Feedzy