@@ -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-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
+ }
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