@@ -79,18 +79,37 @@ Configuring the Command
7979You can optionally define a description, help message and the
8080:doc: `input options and arguments </console/input >`::
8181
82- // ...
83- protected function configure()
84- {
85- $this
86- // the short description shown while running "php bin/console list"
87- ->setDescription('Creates a new user.')
82+ .. versionadded :: 5.3
8883
89- // the full command description shown when running the command with
90- // the "--help" option
91- ->setHelp('This command allows you to create a user...')
92- ;
93- }
84+ The ability to use PHP attributes to configure commands was introduced in
85+ Symfony 5.3.
86+
87+ .. configuration-block ::
88+
89+ .. code-block :: php-attributes
90+
91+ // ...
92+ #[ConsoleCommand(
93+ name: 'app:create-user',
94+ description: 'Creates a new user.'
95+ hidden: false,
96+ aliases: [],
97+ )]
98+
99+ .. code-block :: php
100+
101+ // ...
102+ protected function configure()
103+ {
104+ $this
105+ // the short description shown while running "php bin/console list"
106+ ->setDescription('Creates a new user.')
107+
108+ // the full command description shown when running the command with
109+ // the "--help" option
110+ ->setHelp('This command allows you to create a user...')
111+ ;
112+ }
94113
95114 The ``configure() `` method is called automatically at the end of the command
96115constructor. If your command defines its own constructor, set the properties
@@ -418,7 +437,7 @@ call ``setAutoExit(false)`` on it to get the command result in ``CommandTester``
418437
419438 $application = new Application();
420439 $application->setAutoExit(false);
421-
440+
422441 $tester = new ApplicationTester($application);
423442
424443.. note ::
0 commit comments