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).

Categories: PHP MVC Frameworks Tags:
  1. Sicabol
    April 11th, 2010 at 12:40 | #1

    Take a look at Kohana 3 !

  2. April 11th, 2010 at 14:10 | #2

    Well, looking at Kohana 3 I can certainly say that it is indeed better than Kohana 2.3.4 from the code-completion perspective. I guess the problem with it is it’s still rather new and hence not necessarily something I’d use in production. I’d also be interested to have a look at it’s performance as Kohana 2.3.4 performed significantly worse than Yii. The other thing I don’t particularly like with Kohana 3 is that it’s using inheritance to get around class naming and namespace issues. That’s not too big a deal, but there are other better ways of dealing with the problem. The structure is also not as intuitive, especially for someone who’s used .NET in the past, so in my opinion Yii is still currently the better framework.

  3. Sicabol
    April 15th, 2010 at 07:06 | #3

    Kohana 3 isn’t that new… it was launched on september (?) 2009 and is now 3.0.4. If you take a look to the Kohana forums, most of the questions are about KO3, not KO2. It’s true that the official website has no documentation about KO3, but the link I’ve posted (to the “unofficial” doc) is merely consistant and can help anyone who wants to jump into.

  4. April 16th, 2010 at 00:45 | #4

    No documentation is quite a problem for most, but also as I said it just doesn’t feel natural for the reasons I’ve outlined.

  5. michaw
    May 5th, 2010 at 02:06 | #5

    As a web developer, I have to say how much I enjoy using Yii. It is truly empowering. That being said, the documentation – while comprehensive from a reference point of view – is severely lacking in the example department. Still, Yii makes it much easier and more efficient to develop complex web applications.

  6. May 14th, 2010 at 09:25 | #6

    I like your judgements but the major issue you had CODE COMPLETION and SUGGESTION in Netbeans and Eclipse was solved in kohana 3…so what is the problem. Are you baise now because you are already using YII or what ??
    well Kohana being something that continues from Codeigniter(the best and most easy to use php framework), wins over YII because it will be easy for anybody to learn Codeigniter then specialise in Kohana which is the OOP of codeigniter. does that ring a bell to you ?? its easy for a beginer developer to set with codeigniter/kohana than with YII.
    I have not tried YII but thats my own point of view.

  7. May 15th, 2010 at 04:31 | #7

    Yes, Kohana 3 does indeed support code completion, but I really don’t like the way some things are done in Kohana, for example creating classes that inherit from other classes just so that code completion works. That is pretty dodgy in terms of workarounds. The other thing with Kohana 3 is that its just recently been released. So from the existing frameworks I’d have to say that Kohana 3 would be my second choice after Yii Framework. Please note that I don’t use Yii as my sole framework and in fact there are some things in Yii I find really annoying. For one, I don’t think a framework should be so centred around ActiveRecord and ORM, which is certainly the case with Yii Framework. ActiveRecord and ORM are nice features when you’re building something small and simple, but don’ twork so well the moment you get into anything more complex like having data for an object split between multiple tables. So, in the end out of the existing frameworks, I found that Yii is simply better implemented and certainly has a lot of capabilities. It achieves the right balance of good design, performance and other features I’ve described in my other post titled Choosing the Best PHP MVC Framework

  8. Simon
    June 25th, 2010 at 16:42 | #8

    I think Yii vs Kohana is a pretty pointless comparison as they are pretty much at opposite ends of how frameworks approach things and likely to appeal to different people. Yii takes the approach of doing as much as possible for you (command line tools, javascript / Jquery stuff, etc). Where as Kohana is the complete opposite that deliberately stays minimal, just provides a base and generally attempts to stay out of the way.

    I would of thought what any IDE issues would come secondary to teh gaping difference in philosophy between the two frameworks. But anyway the IDE thig is a non-issue there are several ways to get code completion working for Kohana in Netbeans or Eclipse such as http://www.mybelovedphp.com/2009/01/27/netbeans-revisited-code-completion-for-code-igniter-ii/ . Not they I use either as they both suck compared to Visual Studio (with VS.php).

    A better comparison would be Yii vs Symfony (or CakePHP) and Kohana vs Codeigntier (or even Zend).

  9. June 26th, 2010 at 05:12 | #9

    I disagree, both are PHP frameworks. If you have a read of Gang of Four Design Patterns: Elements of Reusable Object-Oriented Software you get a pretty good consise summary of what a framework vs toolkit is. .NET is a toolkit and some aspects of a framework (but not complete), while Yii and Kohana and Cake and CodeIgniter all try to be full web development frameworks for PHP. What’s important for a framework is completeness, it’s not a very good framework if there isn’t at least a standard way to do things that you commonly do (e.g. lack of templating in CI). Yes, you can use this and that contribution, but ultimately you shouldn’t have to. Both Yii and Kohana are frameworks and hence should fulfil that role. Both are designed specifically for Web Development. To be honest if I had to pick Kohana vs CodeIgniter I’d still probably pick CodeIgniter because of the size of the community and available contributions. But I think ultimately Yii does what you need it to do.

  10. Simon
    July 16th, 2010 at 22:30 | #10


    Yes they are both frameworks (not that I said they weren’t), but then a Rolls Royce and a Lada are both cars, are you getting my drift?

    A frameworks “completeness” is subjective, Yii for instance has a bunch of “core features” that I consider as needless bloat, unnecessary complexity or simply wrong (such as the Jquery intergration, setting up projects with the command line, etc), hence that sort of framework (along with Symfony and CakePHP) would never appeal to me when Kohana, Codeigniter and Zend exist. (and yes I realise Zend has command line features, but it is also by far teh most flexible framework and doesn’t expect you to do things a certain way)

    Likewise I know plenty of people with differing tastes who want to write as little code as possible, want command line stuff, lots of “automagic” and so on, so would never use Kohana or Codeigniter when Symfony, CakePHP and Yii exist.

    The idea that frameworks are all pretty much the same is frankly wrong, but then given this entrie article is based on an incorrect premise (that basic research would of solved), it is no surprise you got that wrong as well.

  11. July 17th, 2010 at 07:19 | #11

    Actually, I have very extensive experience working with various frameworks (both PHP and others including .NET, NetTiers, CSLA and so on). I also have a good understanding of the differences between a framework and a toolkit as described in the GoF book. The evaluation of the PHP frameworks that I did was based on that extensive experience and despite your views I would still very much recommend Yii over CodeIgniter or Kohana to anyone anyday. The reason I think Yii is a better framework is because it’s well thought out that doesn’t use bastardised techniques to get things to work (look at needless inheritance in Kohana 3.x.x just to get code-completion working). Or, look at lack of templating support in CI. Yes, I agree that Yii tries to force you to do things a certain way, which I don’t like either, but you don’t have to use those features (e.g. ORM and ActiveRecord). I started creating my own minimalistic framework which is very similar to the framework used in OpenCart (great work Daniel), but then I found that I was very much rewriting what’s already been done in Yii. The one downside is that Yii being a pretty general framework for PHP web development it has some features (i.e. bloat) that I don’t need and won’t use, however it is very well architected. Don’t get me wrong, Kohana is still a good framework and you’d be better off with Kohana than no framework at all or some other things people try to call frameworks (e.g. DooPHP and some other one that has everything in one file). For me a framework needs to be complete and solve all the common problems a developer is likely to encounter (e.g. Templating is one good example, which CI fails to solve without some add-ons). As for using jQuery I think it makes perfect sense as Yii provides some features which rely on client-side functionality. What Yii has done is decided to use jQuery and I think that’s a great choice as it’s pretty much the de-facto standard for client-side development these days, especially with Microsoft throwing their weight behind it. Ultimately I find Yii to be most similar to .NET and also well rounded and with a large enough community, which is why I believe it’s the better choice. The biggest problem for Kohana is that it’s got a somewhat small community and it is less known than CI or Yii.

  12. Simon
    July 22nd, 2010 at 23:24 | #12

    For me a framework needs to be complete and solve all the common problems a developer is likely to encounter (e.g. Templating is one good example, which CI fails to solve without some add-ons).

    And in a nutshell you’ve demonstrated that you entirely missed the point… Read the first senetence of my first post and see if you can work it out…

    P.S – I’ll give you a clue, your philosphy of a framework is not definitive and indeed is different to those fo frameworks like CI and Kohana.

  13. July 23rd, 2010 at 01:37 | #13

    Simon, my philosophy of a framework is the same as that of a large majority of developers… A framework solves the common problems that a developer is going to encounter, so the developer can focus on the application and not the piping. So in essense Yii is the Rolce Royce, while Kohana/CI are the Ladas. The fact that CI doesn’t do templating as a standard feature shows that it hasn’t been particularly well thought out, Kohana is certainly better, but the problem with it is the small community, relatively weak documentation and workarounds being used where they don’t need to be (e.g. Inheritance to solve a naming and code completion problem). There is no need to get angry… you’re like one of those guys that is prepared to get into a fist fight over Linux vs Microsoft… I have a blog to share my opinions, you should have yours to share your opinions and it’s good to have different opinions so people doing searching on these topics can form their own opinion. In my view with my background (i.e. PHP & ASP.NET) I simply believe Yii is the better choice of framework, that simple.

  14. Simon
    July 23rd, 2010 at 10:38 | #14

    It looks like you will never get the point, it isn’t about which is better, it is about they will appeal to totally different audiences, hence the premise of this article (putting aside that it was actually incorrect), auto-complete in an IDE, is utterly irrelvent when compared to the major differences in the frameworks due to philosphy.

    This will come as a shock to you but using PHP rather than templating is seen as a plus point by most Kohana / CI users, see a different philosphy…

  15. July 24th, 2010 at 05:46 | #15

    The frameworks are there to do the same job… create the piping so you can work on the application, not the piping, so there is nothing wrong with comparing the frameworks. They just go different ways about it. In my view IDE support is also an important consideration, as it significantly improves the productivity.

    Also, just to clarify in relation to templating, what I mean was the concept of template layouts (i.e. overall site, header and footer) (i.e. equivalent of Master Pages in ASP.NET) not templating like Smarty or one of the other languages, as like many I share the view that there is no need to invent a layer on top of PHP to do what PHP does well already.

  16. September 10th, 2010 at 17:13 | #16

    Yii is the framework for me. It is easy to learn and efficient. The documentation needs more examples, but that should be a matter of time. Setting up Yii on Netbeans IDE increases the pace of development.

  17. Roman Solomatin
    October 4th, 2010 at 03:56 | #17

    CakePHP was the first PHP framework that I used. I loved it. Until I noticed that the documentation is not up to date, tutorials were too brain-dead, convention-over-configuration philosophy started to get on my nerves and doing simple things required quite a lot of work. I wanted something simpler and smaller, with better documentation.

    Then I discovered CodeIgniter. I loved it. Until I noticed that code completion does not work in Eclipse, using custom classes required some weird and unnecessary naming conventions. I wanted more OOP.

    Now I have discovered Yii Framework. I love it, so far.

  18. Edemilson Lima
    October 31st, 2010 at 13:25 | #18

    You can get autocomplete in Zend Studio to work with Kohana 2.3.4 using this script:


    It generates a PHP file into the cache folder that handles this issue.
    I think it can work fine with Eclipse too, with a few adjustments.

  19. November 15th, 2010 at 15:49 | #19

    You make your article so much fun to read! “MAJOR NEGATIVE” for auto completion? Stop comparing when you argue over such things, please! It’s so not an issue for comparision, and if you do end up comparing you should certainly not call it “MAJOR”.

    And I’m very sorry to say that I think your a pretty basic developer while making such a statement with such a lack of information. First of all while researching any product, you should always look at the goals (in this case design goals of the project/framework). If they’re similar, which they’re definitely not for Kohana and Yii, you can compare the products.

    Personally I love the development of Yii, but as you look at quality aspects of the framework, it’s almost useless! They say their goal is to create a framework which “easily builds complex applications”, but they have like every garbage module in core you can imagine, right! In fact, they don’t even have any more design goals that I could find in their documentations..

    While Kohana builds from their design goals, Yii feels like a hobby project to me. Though they both have very different meanings if you look at the code. Kohana is very light-weight, where Yii is not. Kohana has a very nice/logic/clean structure, so I don’t get why people say that it’s not well designed, except for class inheritance.

    Overall, I guess it’s almost a non-comparison and I guess it’s a point of knowledge and taste of which you like most!

  20. November 16th, 2010 at 00:35 | #20

    Actually, I’m a very experienced developer and I looked through the core of both Yii and Kohana extensively. Yii is written in a way very similar to ASP.NET MVC and has very similar functionality. The lead developer behind Yii is also very experienced and respected. The reality is Yii has come much further in far less time than Kohana and there’s now even a book on Yii by Packt now, no such thing for Kohana. Community is VERY important when it comes to open source projects and Yii community is much more vibrant. What I don’t like with Kohana is the crappy workarounds with class inheritance, it shows that it hasn’t been well thought through or people didn’t know how to write stuff properly. I would actually almost choose CodeIgniter over Kohana even though Kohana is more complete and a better framework because CodeIgniter has a bigger community.

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

five − = 4