@@ -79,18 +79,37 @@ 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
- 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
88
83
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
90
+
91
+ // ...
92
+ protected function configure()
93
+ {
94
+ $this
95
+ // the short description shown while running "php bin/console list"
96
+ ->setDescription('Creates a new user.')
97
+
98
+ // the full command description shown when running the command with
99
+ // the "--help" option
100
+ ->setHelp('This command allows you to create a user...')
101
+ ;
102
+ }
103
+
104
+ .. code-block :: php-attributes
105
+
106
+ // ...
107
+ #[ConsoleCommand(
108
+ name: 'app:create-user',
109
+ description: 'Creates a new user.'
110
+ hidden: false,
111
+ aliases: [],
112
+ )]
94
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
@@ -418,7 +437,7 @@ call ``setAutoExit(false)`` on it to get the command result in ``CommandTester``
418
437
419
438
$application = new Application();
420
439
$application->setAutoExit(false);
421
-
440
+
422
441
$tester = new ApplicationTester($application);
423
442
424
443
.. note ::
0 commit comments