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
151151:ref: `default services.yaml configuration <service-container-services-load-example >`,
152152this is already done for you, thanks to :ref: `autoconfiguration <services-autoconfigure >`.
153153
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+
154178Executing the Command
155179---------------------
156180
You can’t perform that action at this time.
0 commit comments