SymfonyWorld Online 2021 Winter Edition December 9 – 10, 2021 100% Online +20 talks and workshops

New in Symfony 3.2: Console Improvements (Part 3)

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

Read the part 1 and part 2 of this series of articles explaining the new features of the Console component in Symfony 3.2.

Added support for multiple text style options

Contributed by
in #19495.

The output of the console commands can use any of these text styles to change its appearance: bold, underscore, blink, reverse and conceal. In Symfony 3.2, you can combine more than one text style for a single content (for example to display some text bold and underscored):


In any case, remember that Symfony provides a simpler way to apply the same style to your console commands in a consistent way.

Added support for hidden commands

Contributed by
Jordan Deitch
in #20029.

By default Symfony commands are public, so they are always included in the command listings displayed when running bin/console or bin/console list. In Symfony 3.2, you can remove some commands from those listings hiding them with the setHidden(true) method:

// src/AppBundle/Command/FooCommand.php
namespace AppBundle\Command;

use Symfony\Component\Console\Command\Command;

class FooCommand extends Command
    protected function configure()
            // ...

Hidden commands behave the same as regular commands and they can be executed as before, but they are no longer displayed in command listings, so end-users are not aware of their existence. They are best suited for commands designed for the legacy parts of the application, for commands exclusively executed through scheduled tasks, etc.

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.

New in Symfony 3.2: Console Improvements (Part 3)

Tweet this


Could you give me more examples for private command usage? I'm trying to find relevancy in my projects.
Private commands can be useful when building a CLI application using the standard edition. You might still want to be able to use clear cache and the likes, but don't want them to be displayed to your users.
Wouldn't this effect xml export an therefore IDE autocompletion?
It may be useful
Thanks Loïc, I can imagine better now.

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.