File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,30 @@ with the ``console.command`` tag. If you're using the
151
151
:ref: `default services.yaml configuration <service-container-services-load-example >`,
152
152
this is already done for you, thanks to :ref: `autoconfiguration <services-autoconfigure >`.
153
153
154
+ On PHP 8, you can use native attribute ``AsCommand `` to configure::
155
+
156
+ // src/Command/CreateUserCommand.php
157
+ namespace App\Command;
158
+
159
+ use Symfony\Component\Console\Attribute\AsCommand;
160
+ use Symfony\Component\Console\Command\Command;
161
+
162
+ #[AsCommand(
163
+ name: 'app:create-user',
164
+ description: 'Creates a new user.',
165
+ hidden: false
166
+ aliases: ['app:add-user']
167
+ )]
168
+ class CreateUserCommand extends Command
169
+ {
170
+ // ...
171
+ }
172
+
173
+ .. versionadded :: 5.3
174
+
175
+ The ability to use PHP attributes to configure commands was introduced in
176
+ Symfony 5.3.
177
+
154
178
Executing the Command
155
179
---------------------
156
180
You can’t perform that action at this time.
0 commit comments