You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #59473 [Console] Add broader support for command "help" definition (yceruto)
This PR was squashed before being merged into the 7.3 branch.
Discussion
----------
[Console] Add broader support for command "help" definition
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | -
| License | MIT
Follow up #59340
Invokable and regular commands can now define the command `help` content via the `#[AsCommand]` attribute.
This is particularly useful for invokable commands, as it avoids the need to extend the `Command` class.
```php
#[AsCommand(
name: 'user:create',
description: 'Create a new user',
help: <<<TXT
The <info>%command.name%</info> command generates a new user class for security
and updates your security.yaml file for it. It will also generate a user provider
class if your situation needs a custom class.
<info>php %command.full_name% email</info>
If the argument is missing, the command will ask for the class name interactively.
TXT
)]
class CreateUserCommand
{
public function __invoke(SymfonyStyle $io, #[Argument] string $email): int
{
// ...
}
}
```
Cheers!
Commits
-------
e9a6b0a [Console] Add broader support for command "help" definition
0 commit comments