@@ -79,19 +79,38 @@ Configuring the Command
79
79
You can optionally define a description, help message and the
80
80
:doc: `input options and arguments </console/input >`::
81
81
82
+ // ...
83
+ // the command description shown when running "php bin/console list"
84
+ protected static $defaultDescription = 'Creates a new user.';
85
+
82
86
// ...
83
87
protected function configure(): void
84
88
{
85
89
$this
86
- // the short description shown while running "php bin/console list"
87
- ->setDescription('Creates a new user.')
90
+ // If you don't like using the $defaultDescription static property,
91
+ // you can also define the short description using this method:
92
+ // ->setDescription('...')
88
93
89
- // the full command description shown when running the command with
90
- // the "--help" option
94
+ // the command help shown when running the command with the "--help" option
91
95
->setHelp('This command allows you to create a user...')
92
96
;
93
97
}
94
98
99
+ Defining the ``$defaultDescription `` static property instead of using the
100
+ ``setDescription() `` method allows to get the command description without
101
+ instantiating its class. This makes the ``php bin/console list `` command run
102
+ much faster.
103
+
104
+ If you want to always run the ``list `` command fast, add the ``--short `` option
105
+ to it (``php bin/console list --short ``). This will avoid instantiating command
106
+ classes, but it won't show any description for commands that use the
107
+ ``setDescription() `` method instead of the static property.
108
+
109
+ .. versionadded :: 5.3
110
+
111
+ The ``$defaultDescription `` static property and the ``--short `` option
112
+ were introduced in Symfony 5.3.
113
+
95
114
The ``configure() `` method is called automatically at the end of the command
96
115
constructor. If your command defines its own constructor, set the properties
97
116
first and then call to the parent constructor, to make those properties
0 commit comments