Yii is a framework, not a system. I think it would be awkward to use pieces from other frameworks.
An acceptable option would be to leave the choice to the developer.
If You want Symfony console, add “this” to your composer.json
If You want Yii 3 console, add “that” to your composer.json
We could start with the Symfony only and slowly improve our own util can make it the default console and Symfony becomes an option.
Multiple action controllers aren’t good idea for console commands considering dependency injection via constructor. Options and argument definitions could be easily ported over. What parts do you think are particularly good?
This depends on specific case. I would say that in most of cases it is completely irrelevant - if your console controllers have sane scope and do not group many completely irrelevant actions, injecting all dependencies in controller constructor should not be a problem. And even if you will get some injected but unused dependencies, you can usually ignore it (console controllers have much lower load than web controllers, so performance impact is negligible).
I would rather try creating wrapper if Symfony Console lacks some features - maintaining a fork of an active package may require more work than creating wrapper or completely new implementation.
Another thing, maybe slightly OT, but … could we migrate to a syntax like yii ctrl action without the slash? Most CLI tools use this kind of syntax and I can’t remember a single one using a /.
Actually, I like current syntax and I think it was a huge improvement compared to Yii 1.1 (which uses ./yiic controller action arguments syntax) - it is more consistent with web controllers and how routing in Yii works, so it is much more intuitive for me. It is also much clear what part of the command is a route to action and what part is the action arguments.
AFAIK they don’t have controllers at all, only actions (commands). Using : is only a convention to group commands in namespaces, but there is no restrictions for this (you probably could use / instead). In this context it is simillar to Yii 2 - there is one argument for command name/route.
@rob006 is correct. There’s a single argument for it in Symfony.
For now I’ve adopted Symfony Console directly. Going to focus on other parts for a while. If you want to take care about having our own interfaces meanwhile, let me know.
I just stumbled upon https://climate.thephpleague.com/ - would it be possible to integrate it in Yii 3.x or would it rather be a replacement of the console tool?
Metadata of the command isn’t static so all the commands are instantiated, thus depdendency resolving is triggered for every single command all the time.
For me, the answer is very simple, Yii2 has all the code that is needed for Yii3, obviously we are changing the patterns, and the Yii2 code has many shortcomings in terms of magical methods, service locator, but after more than 10 years created, it is widely used by many people.
Yii has always been different from all frameworks, because we must be equal to all other PHP frameworks in Yii3.