Skip to content

[Console] Add ConsoleCommand attribute for declaring commands on PHP 8 #40234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

Builds on #39851

On PHP8, this PR will allow using an attribute instead of the public static properties for the name and the description.

#[ConsoleCommand(
	name: 'app:my-command',
	description: '🌈',
	hidden: true,
	aliases: ['🌈'],
)]
class MyCommand extends Command
{
}

@nicolas-grekas nicolas-grekas added this to the 5.x milestone Feb 18, 2021
@carsonbot carsonbot changed the title [Console] Add ConsoleCommand attribute for declaring commands on PHP 8 Add ConsoleCommand attribute for declaring commands on PHP 8 Feb 18, 2021
@nicolas-grekas nicolas-grekas changed the title Add ConsoleCommand attribute for declaring commands on PHP 8 [Console] Add ConsoleCommand attribute for declaring commands on PHP 8 Feb 18, 2021
@javiereguiluz
Copy link
Member

This is nice! Thanks!

Minor comment about naming: what if we rename #[ConsoleCommand] as #[Command] ? I think "command" is a pretty "universal" and standard way of calling "console commands".

Also, if we create attributes for other "commands" in the future (CommandHandler, CommandBus, etc.) their names will always contain more than just "command" because that's commonly reserve for CLI/console.

@nicolas-grekas
Copy link
Member Author

at if we rename #[ConsoleCommand] as #[Command]

that's what I did at first, until I realized that all command class extend... Command. The name is already in use in the same file 99% of the time.

@chalasr
Copy link
Member

chalasr commented Feb 19, 2021

Thank you @nicolas-grekas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants