Hi,
I should say I am not familiar with Kohana and the only php framework I user for real projects is Yii, but I am always interested in learning other frameworks / libraries to get some new good ideas or examples of solutions for some complex problems. For example, I used some Zend components, some ideas form Ruby on Rails and Fat-Free micro-framework.
Before starting with Yii I developed desktop applications in C++. I’am writing this because I want to say I seen many code of many software products in different programming languages and I can say that Yii is definitely one of the most good written, well documented and true OOP code I ever seen.
And yes, the code conventions in the Yii sources are not usual. I can not say my eyes were bleeding (as say some people on the Kohana forum), but it was difficult to understand from the first sight - just because on unusual look. But this is just a habit and no one can say that the code is bad just because if formatted not in the way someone expected.
After week or two working with Yii I just realized that the code style does not disturbs me any more and now I even like it (and even more have a thoughts to use it in my projects).
This is because Yii code conventions have a practical background:
-
tabs and not spaces (this is also used in the Kohana, so possible not a problem for you): less typing and smaller file size
-
no extra spaces: more compact code and as the result more code fits on the screen while reading / writing)
-
CamelCase - this is what I just like because always used it
-
and so on
What I still do not like (also because of practical reason) is no brackets for single line statements, because it complicates debugging:
if ($this->checkSomething() && $this->checkSomethingElse())
$this->doSomething()
In that case when I step line by line I can not step over $this->checkSomething() and $this->checkSomethingElse() and should go inside to finally get into $this->doSomething().
And now some comments for you points at the Kohana forum:
> Strict development - Kohana being really strict about it’s additions / conventions
Yii uses "convention over configuration" approach, but also gives you a chance to change defaults if you want or need this.
In most cases you just can follow default conventions, without need for configuring everything.
> Unit tests - Kohana being completely unit tested
Yii also is well tested. I can not say anything about percent of code coverage, but you can look at existing tests here - http://code.google.com/p/yii/source/browse/#svn%2Ftrunk%2Ftests
> Userguide - ability to have the whole framework and application (with API) documented ‘automatically’
Yii has custom command (can be found in svn - http://code.google.com/p/yii/source/browse/trunk/build/commands/ApiCommand.php) to generate framework documentation.
It is not complex to customize this command to generate documentation for your project or for your project + framework code. You just need to follow PHP Documenter conventions.
> Actual OOP
As I said above, I think that Yii is a great example of true OOP project.
> No pattern abuse / misuse (e.g. having the Event / Behavior patterns in Yii opposed to Kohana where nothing ‘hacky’ like that is used)
This is not right to say about abuse or misuse of patterns just because Kohana does not use Event and Behavior.
Both of these patterns and its implementation in the Yii CComponent gives you really great flexibility in extending objects without inheritance or even "on-the-fly".
And also you do not have to use them, its just an option (but very good option and it worth to learn and use it).
> No convention abuse - Yii has quite a few convention flaws, e.g. using eval() "natively"
Can not understand what definitely you mean here. Yii does not use "eval" to do some important things, just in a few places to allow more flexible configuration (like business rules in the RBAC configuration or specifying php expression for cache dependencies and also in some widgets).
> Actual hierarchy - Kohana has class naming / file system placement conventions strictly defined opposed to Yii where … classes can be all over the place
Yii has defined convention on where to place classes and how to name them. You can use some additional folders if you need this and do explicit import, but I think you can do the same in Kohana too.
Also code generation features allows you build a project skeleton and generate controllers / models / views - all in appropriate places and named regarding to convention.
> Modularity - the ease of adding modules and overriding / extending framework’s classes inside of them
Can say the same about Yii.
> HMVC - being "what PHP always missed", having a useful pattern like this and respecting the RFC 2616
I read some docs about HMVC in Kohana and it seems that it is different from classic MVC because of "rerouting" feature - when you execute other controller/action from the current action, right?
In Yii you can do the same using forward() controller method, like this:
public function actionComplexPage() {
if (some_condition) {
$this->forward('controllerX/actionY');
}
}
> Know what the framework is doing by reading it’s clean, well documented code (opposed to Yii where the coding convention itself isn’t readable, not to mention having the whole method commented before it’s definition only)
Again I can say the same about Yii (except for unusual code style which is a problem only at the beginning).
> You want to program and not write arrays
What do you mean?
In Yii you always can extend base class instead of configuring it. And in some cases it is even easier, but this is always up to you - extend or configure.
In the conclusion: I think every popular framework or library with large number of users (like Yii or Kohana or Symfony) does its framework’s job well. Otherwise how it become popular? I never seen an advertisement of Yii or Kohana on TV )). Every framework can have some unique and good features, but talking about “Framework1 VS Framwork2” is always leads to some users holy war.
So if you familiar with Kohana then now you have a great opportunity to learn Yii and know the best sides of each, so you will be able to make both of them better by contributing ideas and feature requests or porting some components.