Home » PHP » PHP MVC Frameworks » Why Yii Framework is better than Kohana PHP

Why Yii Framework is better than Kohana PHP

Recently I’ve set out comparing and choosing the best PHP MVC Frameworks so that I could then decide if I’m going to use an existing framework or roll my own minified super-efficient framework, because most frameworks seem too bloated for my liking these days (and hence run poorly on shared hosting).  Two of the frameworks I short-listed were Yii Framework and Kohana PHP.  After spending considerable time playing around with both I’ve come to the conclusion that Yii Framework is better than Kohana PHP. Here’s why…

I started playing around with both Yii and Kohana in the two PHP IDEs that I use, Eclipse PDT + Aptana and NetBeans PHP.  Yii played very nice with both, because it seems the developers also use these IDEs and hence thought about something that’s very important to serious PHP developers IntelliSense / Code Completion.  Yii handles code completion perfectly and I can easily press F3 in Eclipse PDT or right-click Navigation->Go to Declaration in Net Beans PHP to go into the source object and see what’s going on.  In Kohana however, this is not possible and that’s a MAJOR NEGATIVE, because it makes learning the framework so much more difficult as you don’t have code completion.  This stems from how Kohana does auto-loading (and it’s not alone, I’ve seem the same problem in the custom framework that OpenCart uses).  Basically it uses a registry and a loader class but there isn’t a one-to-one relationship between the class name and what it’s called when used.  For example, the html helper in Kohana is declared as html_Core, while when used it’s usually html::somestaticmethod.  Because html_Core is not html the IDE can’t make the connection!  Also, why does Kohana use lowercase for helper classes?  The standard is generally to use ProperCase for class names and camelCase for variables (and usually for functions).  This issue with IDE support is in itself for me a reason to choose Yii over Kohana!

Other things that make Yii the better choice for me are the fact that when I use it, it just feels natural!  It’s like the lighter version of .NET and Zend and with CodeGeneration capabilities so I don’t have to write everything by hand.

Performance wise both are about the same, but I’ll write a separate post on performance as I benchmarked both.

Regardless, all other thigns aside, the lack of proper IDE Code Completion support in Kohana is a deal-breaker for me and is a big enough reason to choose Yii Framework over Kohana!  Unless you’re already super familiar with Kohana or are stuck in the dark ages (or think you’re tool l33t for an IDE), using Yii will greatly improve the speed with which you’ll be able to get up and running with a new framework.  Combine that with code generation that Yii provides and you’re onto a winner unless of course it doesn’t meet some other needs that you have and you prefer to roll your own (which requires a significant investment of time and skill).

  • Share/Bookmark
Categories: PHP MVC Frameworks Tags:
  1. John
    December 7th, 2011 at 04:11 | #1

    In RoR it is possible to define pure sql commands in models using specific instruction case we don’t want to use the Active Record.

    Is it possible to do the same in Yii? Thanks!

  2. December 7th, 2011 at 04:27 | #2

    Yes, if you want to write SQL statements you can do so in Yii as well quite easily. Just override the specific method in your particular model and do as you wish.

  3. Andrew R
    April 21st, 2012 at 19:48 | #3

    @Nick Rappoldt

    I think it is fairly clear from the comment discussion on this topic, that the author doesn’t get different frameworks have different goals, different ways of approaching things and appeal to differnet audiences.

    For me I like Zend the best of the PHP frameworks, it is well written, well supported and is by far the most flexible.

    Codeigniter is simply badly written (and last time I checked, which granted is a while ago was still basically using php4).

    Kohana has a bad community / bad documentation, but is at least written well and achieves its aims of a sort of minimal, cleanly written framework.

    Cakephp had performance issues and is a RoR wannabe, I’d rather use RoR it is better.

    FInally Yii, it has some nice ideas, decent documentation, a reasonable community, but on the other hand it lacks the flexibilty all bult-in magic behind the scenes frameworks lack, is bascially just another ROR wannabe with some .net ideas bolted on, so as with CakePHP, I’d rather go with the originals than an inferior PHP version.

    I’d also add on the Yii front, I really dislike how they initially marketed it on the “alleged” performance tests, which are really biased and not at all realistic, but then even a fresh CS graduate knows “hello world” is worthless.

  4. Andrew R
    April 21st, 2012 at 19:57 | #4

    Whoops I forget, saying all that, I’d just add the best framework is the one that suits the individual developer, given the amount of time someone is going to be spending with a framework the best option* will be whatever one they ‘click’ with.

    * – Putting aside considerations like employemtn prospects, in whcih cas neither Yii or Kohana come out very well, Zend or that awful mess of a CMS that is Drupal are best as far as PHP goes.

  5. April 22nd, 2012 at 00:07 | #5

    I do agree that the problem with Yii is that it’s really designed to work with ActiveRecord and if you try to take it too far out of that realm it’s a bit of a struggle. It’s a great framework if you’re developing an app from scratch, but doesn’t work very well with databases which aren’t particularly well designed. The Mapper pattern used in Zend Framework is far more flexible than ActiveRecord. I too prefer Zend framework for that reason and because I don’t need to look elsewhere for all the bits and pieces like mailing, html parsing and so on because it’s all there in Zend. That is a bit of an annoyance with Yii as you need to decide whether to use Zend_Mail, SwiftMailer, PHPMailer and so on and they all need to be bolted in sometimes in somewhat odd ways because there are so many ways to do things in Yii. If you want a framework that will just do everything for you just go with Zend, if you’re developing from scratch and don’t mind or prefer strict ActiveRecord (i.e. your app is not too complex) then go with Yii and if you want something simplistic but don’t want to do everything from scratch go with CodeIgniter. As I said before I think Kohana sucks because it’s rather poorly designed (seems designers didn’t have a very good grasp of OO).

Comment pages
1 2 3 37
  1. April 15th, 2010 at 17:50 | #1