@@ -70,19 +70,38 @@ Configuring the Command
7070You can optionally define a description, help message and the
7171:doc: `input options and arguments </console/input >`::
7272
73+ // ...
74+ // the command description shown when running "php bin/console list"
75+ protected static $defaultDescription = 'Creates a new user.';
76+
7377 // ...
7478 protected function configure(): void
7579 {
7680 $this
77- // the short description shown while running "php bin/console list"
78- ->setDescription('Creates a new user.')
81+ // If you don't like using the $defaultDescription static property,
82+ // you can also define the short description using this method:
83+ // ->setDescription('...')
7984
80- // the full command description shown when running the command with
81- // the "--help" option
85+ // the command help shown when running the command with the "--help" option
8286 ->setHelp('This command allows you to create a user...')
8387 ;
8488 }
8589
90+ Defining the ``$defaultDescription `` static property instead of using the
91+ ``setDescription() `` method allows to get the command description without
92+ instantiating its class. This makes the ``php bin/console list `` command run
93+ much faster.
94+
95+ If you want to always run the ``list `` command fast, add the ``--short `` option
96+ to it (``php bin/console list --short ``). This will avoid instantiating command
97+ classes, but it won't show any description for commands that use the
98+ ``setDescription() `` method instead of the static property.
99+
100+ .. versionadded :: 5.3
101+
102+ The ``$defaultDescription `` static property and the ``--short `` option
103+ were introduced in Symfony 5.3.
104+
86105The ``configure() `` method is called automatically at the end of the command
87106constructor. If your command defines its own constructor, set the properties
88107first and then call to the parent constructor, to make those properties
0 commit comments