@@ -80,26 +80,36 @@ You can optionally define a description, help message and the
80
80
:doc: `input options and arguments </console/input >`::
81
81
82
82
// ...
83
- // the short description shown while running "php bin/console list"
83
+ // the command description shown when running "php bin/console list"
84
84
protected static $defaultDescription = 'Creates a new user.';
85
85
86
86
// ...
87
87
protected function configure(): void
88
88
{
89
89
$this
90
- ->setDescription(self::$defaultDescription)
90
+ // If you don't like using the $defaultDescription static property,
91
+ // you can also define the short description using this method:
92
+ // ->setDescription('...')
91
93
92
- // the full command description shown when running the command with
93
- // the "--help" option
94
+ // the command help shown when running the command with the "--help" option
94
95
->setHelp('This command allows you to create a user...')
95
96
;
96
97
}
97
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
+
98
109
.. versionadded :: 5.3
99
110
100
- The ``$defaultDescription `` static property was introduced in Symfony 5.3.
101
- It allows to make the ``php bin/console list `` lazy.
102
- You can as well use ``php bin/console list --short `` option to have the output faster.
111
+ The ``$defaultDescription `` static property and the ``--short `` option
112
+ were introduced in Symfony 5.3.
103
113
104
114
The ``configure() `` method is called automatically at the end of the command
105
115
constructor. If your command defines its own constructor, set the properties
0 commit comments