Yii Framework Forum

Yii values and goals

(Jiuly Rojas) #21

Congratulations, I like it. I think it’s excellent that it’s flexible and simple. Making it more flexible and simpler is the goal :yii:

(shane) #22

I read the docs, and I am curious about that No magic unless necessary - Be Explicit. Why?


Magic means it is unclear what is going on in the code you are looking at. Better write explicit code that is easy to understand instead of writing code that you can only understand if you dig into the functionality and learn about all the internals.

(shane) #24

Yep, thanks for you explanation.

(Jacob Moen) #25

It is if you put it in the right context. If I am not too mistaken, it is from Ruby On Rails, and means that we rely more on putting files in the right folders than configure it.
Take Composer and it’s autoloader. A good example of Convention Over Configuration. Plop the correctly named files in correctly named folders, and you don’t have to configure much, if anything.

(Fsb) #26

Putting a file in a specific place is configuration. The hosts file has to be in the right place. Putting it there is part of configuring a system.

Working with composer feels exactly like configuration to me. There’s a config file and I have to get it right. Everything else is behind the scenes to me.

Rail’s marketing was sometimes rather poetic.


No, it is convention (at least if this place is standardized in some way). Configuration would be if you put this file in some random place and then configure your system to use it instead read from default/standard path.

(Jacob Moen) #28

“Convention Over Configuration” is widely well understood:

attempts to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility.

IMO, if you want to be succinct, “convention over configuration” is extremely accurate with regards to Yii2.

Remember how Yii 1 extensions used to work, before Yii2 and Composer?
I shudder to think about it. PSR-4 is pure C over C. :wink:

(Fsb) #29

I see. So configuration over convention is normal. It’s how most computer configurations are done. It’s an odd terminology. I took a browse through the 60 salt files and 100 config files/templates that I use to configure my servers, and all this time I didn’t know it wasn’t configuration but convention. Is there a verb form for this? “Next I need to convention the network interfaces.” “Did you forget to convention the timezone.” ?

Joking aside, the phrase is saying that Yii doesn’t hold doing things in a stupid way as a goal. Why bother? I would prefer positive assertions of the qualities of Yii. Seems to me the purpose of this slogan is more about dissing something else than saying what Yii did unusually well.

(Jacob Moen) #30

@thefsb Saying that Yii uses Convention over Configuration is an extremely precise way of stating how it works.
Configuration is very specific. :wink:

(Fsb) #31

then i will shut up


Only if you assume that configuration is stupid (which is incorrect). Most of the software mixing conventions and configuration. Even in Yii most of the conventions can be overridden by configuration or custom components with few lines of code. It is only a matter of which way is preferred. You can easily compare how console commands work in Yii vs Symfony - in Yii command name is (by default) bound to class name/route (convention) and in Symfony there is a separate property for it (configuration). None of this solutions is stupid, they’re just different.

(Jacob Moen) #33

What I mean is that you can’t just make up a meaning for a well-defined term. (For the sake of winning the argument).

When Yii is using Convention over Configuration, it means that I know exactly what I can expect.
It also very easy to look at new Yii-based code because the structure - the convention - ensures that I know where things are.

You can disagree about the practice, but you can’t make up your own definition of what it means.
That’s all. :wink:

Please, don’t shut up about the other things you mentioned.