Cons and pros of using Symfony Console

I second that!

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.

3 Likes

To me the similarity to web controllers was always more confusing than helpful.

How does Symfony Console handle this … AFAIK with a colon :?

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.

Poll about the syntax: What would be your preferred console syntax?

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?

Bonus question: What’s about Yii 2?

There are no problems for using Climate with yii2
see https://github.com/Insolita/yii2-codestat/blob/master/src/controllers/DefaultController.php

If yii3 will use symfony-based console see https://github.com/duncan3dc/symfony-climate/blob/master/src/Output.php
example

Yet another pros for symfony-based console is may be better compatibility/adoption with existed symfony/console decisions

Is it no problem, that it does not use $this->stdout()?

Seems i don’t understand you. You want to output climate formatted data via yii $this->stdout()?

You also can do it, for example via buffer

see https://climate.thephpleague.com/output/

1 Like

Nice, thank you!

Faster (in implementation) solution at the beginning, with time, if necessary, own implementation.

And… here’s finally a very strong conceptual flaw in Symfony console: https://github.com/yiisoft/yii-console/issues/46 :frowning:

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.

1 Like

@vanhelvzla it’s not that simple and the reason for starting with Symfony console was actually non-technical. Yii 2 console is OK, with some polishing it can get even better. The reason back there was basically lack of hands. Now that you and other contributors are more active, I’m not feeling as strong towards not having to support our own solution.

1 Like