Skip to content

Commit

Permalink
minor #20247 [Console] Document the silent verbosity level (javieregu…
Browse files Browse the repository at this point in the history
…iluz)

This PR was squashed before being merged into the 7.2 branch.

Discussion
----------

[Console] Document the silent verbosity level

Fixes #20243.

Commits
-------

2492dd1 [Console] Document the silent verbosity level
  • Loading branch information
javiereguiluz committed Sep 27, 2024
2 parents b8a153d + 2492dd1 commit 4fcdb8f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
8 changes: 8 additions & 0 deletions components/console/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ You can suppress output with:

.. code-block:: terminal
# suppresses all output, including errors
$ php application.php list --silent
# suppresses all output except errors
$ php application.php list --quiet
$ php application.php list -q
.. versionadded:: 7.2

The ``--silent`` option was introduced in Symfony 7.2.

You can get more verbose messages (if this is supported for a command)
with:

Expand Down
7 changes: 6 additions & 1 deletion console/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,17 @@ The Console component adds some predefined options to all commands:

* ``--verbose``: sets the verbosity level (e.g. ``1`` the default, ``2`` and
``3``, or you can use respective shortcuts ``-v``, ``-vv`` and ``-vvv``)
* ``--quiet``: disables output and interaction
* ``--silent``: disables all output and interaction, including errors
* ``--quiet``: disables output and interaction, but errors are still displayed
* ``--no-interaction``: disables interaction
* ``--version``: outputs the version number of the console application
* ``--help``: displays the command help
* ``--ansi|--no-ansi``: whether to force of disable coloring the output

.. versionadded:: 7.2

The ``--silent`` option was introduced in Symfony 7.2.

When using the ``FrameworkBundle``, two more options are predefined:

* ``--env``: sets the Kernel configuration environment (defaults to ``APP_ENV``)
Expand Down
23 changes: 20 additions & 3 deletions console/verbosity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ messages, but you can control their verbosity with the ``-q`` and ``-v`` options

.. code-block:: terminal
# do not output any message (not even the command result messages)
# suppress all output, including errors
$ php bin/console some-command --silent
# suppress all output (even the command result messages) but display errors
$ php bin/console some-command -q
$ php bin/console some-command --quiet
Expand All @@ -23,13 +26,18 @@ messages, but you can control their verbosity with the ``-q`` and ``-v`` options
# display all messages (useful to debug errors)
$ php bin/console some-command -vvv
.. versionadded:: 7.2

The ``--silent`` option was introduced in Symfony 7.2.

The verbosity level can also be controlled globally for all commands with the
``SHELL_VERBOSITY`` environment variable (the ``-q`` and ``-v`` options still
have more precedence over the value of ``SHELL_VERBOSITY``):

===================== ========================= ===========================================
Console option ``SHELL_VERBOSITY`` value Equivalent PHP constant
===================== ========================= ===========================================
``--silent`` ``-2`` ``OutputInterface::VERBOSITY_SILENT``
``-q`` or ``--quiet`` ``-1`` ``OutputInterface::VERBOSITY_QUIET``
(none) ``0`` ``OutputInterface::VERBOSITY_NORMAL``
``-v`` ``1`` ``OutputInterface::VERBOSITY_VERBOSE``
Expand Down Expand Up @@ -58,7 +66,7 @@ level. For example::
'Password: '.$input->getArgument('password'),
]);

// available methods: ->isQuiet(), ->isVerbose(), ->isVeryVerbose(), ->isDebug()
// available methods: ->isSilent(), ->isQuiet(), ->isVerbose(), ->isVeryVerbose(), ->isDebug()
if ($output->isVerbose()) {
$output->writeln('User class: '.get_class($user));
}
Expand All @@ -73,10 +81,19 @@ level. For example::
}
}

When the quiet level is used, all output is suppressed as the default
.. versionadded:: 7.2

The ``isSilent()`` method was introduced in Symfony 7.2.

When the silent or quiet level are used, all output is suppressed as the default
:method:`Symfony\\Component\\Console\\Output\\Output::write` method returns
without actually printing.

.. tip::

When using the ``silent`` verbosity, errors won't be displayed in the console
but they will still be logged through the :doc:`Symfony logger </logging>` integration.

.. tip::

The MonologBridge provides a :class:`Symfony\\Bridge\\Monolog\\Handler\\ConsoleHandler`
Expand Down

0 comments on commit 4fcdb8f

Please sign in to comment.