Discussion: Yii coding style and naming conventions

Hello everyone,

I’m a professional Drupal and WordPress developer.

Recently certain projects asked to go beyond the boundaries of both those systems and create portals/websites which are completely custom.

The choice I am facing is either to take a framework and learn it or to build something from the scratch. The latter one is completely unnecessary in my opinion, unless you will make something huge and with unique workflow, logic or requirements.

This is how I came to Yii.

Yii has almost everything that was on my checklist and I am still impressed by the features. Code generation, security, themes, authentication, cache implementation and most importantly, excellent references.

However, two things made it impossible for me to use Yii for a bigger project: coding standards and naming conventions.

I am sure that I’m not the first person complaining about it. I read on several forums/blogs that people mentioned this as a major drawback of the framework.

I have been test playing with Yii quite a lot and my eyes bleed because of one line if statements, imitating python with missing curly brackets etc. Before each test project I adjusted the code style so it becomes "readable" and only then I was able to work further.

Naming conventions are completely off the hook and unreasonable for me. Mixing camel case and underscores is confusing and doesn’t make sense often.

Is this going to change in Yii 2.0? Is this going to be different in the future?

Any inputs that will explain why the things are this way?

Constructive thoughts are very much welcome :)


It’s nice to have good naming conventions and one line “if” statements are a personal bugbear of mine. All considered though, I don’t think Yii is too bad in that respect, especially in comparison to Drupal which you mentioned. That is just a mess when you start looking into it properly.

I’m sure there are topics in the wiki with some good convention guidelines but a lot of it is down to personal preference. Yii has never been one to force your hand in a certain direction.

  1. There’s no coding standard in Yii. There’s a style core framework code is following. Application code standards are up to you to choose and follow.

  2. Yes, in Yii2 core framework code style will be K&R brackets, brackets for one-liners, more spaces etc. Still, I don’t think we should force following these.

You are mixing misunderstanding of the code/lack of knowledge with coding standards.

Drupal is strict about coding style and naming conventions.

It has much bigger community than Yii and quite a few big teams/companies behind, so saying that the core is a mess is not serious at all.

I don’t want this to be a discussion on this topic though.

Thanks for the reply Sam; as you’re involved in the Yii team, I’ll consider this a direct response to my question.

I resisted for a while but no.

You tore into Yii with some whiny comments about "coding style" and "naming conventions" after coming from a background in Drupal, whose "coding style" in the core is good, but such a shame the code itself is awful.

“Constructive thoughts are very much welcome”… just don’t say anything bad about Drupal because my Dad’s bigger than your Dad.

Self opinionated much?

Hi, not sure if this helps, but Yii recommends a few code naming conventions and table design guidelines. For example:



Best regards,


There’s Yii core code style now: https://github.com/yiisoft/yii/wiki/Core-framework-code-style