-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC] Add static method + interface to get command names at compile time #23796
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
Comments
Instead of just defining the name, we could define the entire command signature (like Laravel does). This would save us all the verbosity required to define a command. |
@javiereguiluz, creating a DSL for command configuration is something else, that's for another RFC :) |
why the new interface? we can simply add this to Command no? |
This has been suggested by @weaverryan and briefly discussed in #22734.
The idea is not to replace the tag nor to make Application aware of this method but just to fill the tag attribute by calling it from the pass. 👍 as it makes laziness accessible to autoconfigured commands. |
But
:S wouldnt |
@chalasr thanks for the link. There is no pb to me to make this static method if it is really an easilly overrideable default, which is what I'm suggesting to do. You can think of it like an annotation that is parseable by PHP itself. |
Going to pick this one. |
DefaultNameProviderInterface |
… compile time registration (chalasr, nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [Console] Allow commands to provide a default name for compile time registration | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23796 | License | MIT | Doc PR | symfony/symfony-docs#8147 Commits ------- eda7d42 [Console] Add protected static $defaultName to set the default name of a Command 5d9ae6b [Console] Allow commands to provide a default name for compile time registration
With PSR-4-based service definitions, we can declare command as services. But this doesn't provide laziness for them, because we don't know their name at compile time.
To enhance that, what about adding a new static method + related interface to commands, ?
Eg.
That would also enable auto-configuration of commands. The method would be called to fill in the "name" attribute of the "console.command" tag when none is set.
ping @chalasr
The text was updated successfully, but these errors were encountered: