File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,29 @@ 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+ aliases: [app:add-user']
166+ )]
167+ class CreateUserCommand extends Command
168+ {
169+ // ...
170+ }
171+
172+ .. versionadded :: 5.3
173+
174+ The ability to use PHP attributes to configure commands was introduced in
175+ Symfony 5.3.
176+
154177Executing the Command
155178---------------------
156179
You can’t perform that action at this time.
0 commit comments