6 months ago I had no idea what a PHP framework was, I had been programming in PHP for over 3 years but had not yet come across the idea of MVC.

I was first introduced (by a friend) to CI and for a while used that as my main toolkit. After a while I happened by chance on Kohana. Yesterday I picked up CI after a 3 month haitus and thought it would be a nice idea to jot down some of my thoughts about the 2 frameworks.

Meet the teams

On the left we have CI (Code Igniter 1.6); a mature, stable and fast MVC framework. It's been around the block a bit and has the scars to prove it - but it's a serious work horse and gets the job done. On the right we have K2 (Kohana 2.1) the bolshy new boy (and son of CI!) with a fast moving development cycle and new innovation.

CI was my first framework so I do have some *emotional* attachment to it, that said it is a love-hate relationship. Sure it is easy to code for but often the syntax is.. kooky.. and it does make you jump through some hoops. That said I do enjoy the fact you can pick up 3 or 4 of the custom libraries, whack some code into a controller and have a working site in under a day (or thereabouts :P).

Kohana on the other hand has been a love/hate thing. It's major failing is twofold. Firstly the documentation is a little light (but improving) the other is that there seems to be no published plan of campaign byt the developers (apart from the roadmap to version 2.2). The first of those reasons might be killer for newer developers but was never a problem for me - I enjoy hacking about with the code (I always run with the latest SVN Head) to find out how it works. In fact K2 has taught me LOTS of stuff about PHP I didn't know before.

I wouldn't say I am biased to either framework - I can use both adeptly and have bits of code / tools hanging about allowing me to develop quickly. So lets take a bit of an objective look at some of the things I personally look for in a framework.

R1: Stability

I do like things to be stable. Not so much in terms of running smoothly (I can take a bit of hacking to keep things ticking over on low traffic sites) but rather in terms of the API. One of the things I like about CI is how stuck-in-the-mud it's API is. Nothing much is going to change there (I suppose your could say that this is a bad thing...) and so I feel safe rolling updates out to sites built on CI without exhaustive checking.

K2 on the other hand is being massively revamped even now. I couldn't take version 2.2 a plonk it into my sites and feel happy (in fact I am pretty sure it IS going to break stuff and we will be told as much). It's not a huge issue but it does make me cautious about developing large applications which may later need fully reworking.

I suppose I could hold off updates to the Kohana system but the changes being made are very cool and exciting and I want to make use of them - catch 22.

Round 1 seems a bit of a draw, great start :P.

R2: File layout

Sorry CI, Kohana has you destroyed in this respect. The freedom to move the application directory to where the hell you like (I know the same can be done with CI but not out of the box) and to share system files is excellent. The built in modules system also kicks ass - I am developing a set of sites know which share a lot of controllers / data and modules makes it really easy to do (I cant imagine trying to get it working easily on CI!).

Finally the configuration method employed by K2 is cleaner and quicker than CI.

Round 2 is decisively Kohana's.

R3: Code layout / methodology

This one is a toughie for me. Because K2 is PHP5 only it has huge advantages over CI (which still has to support PHP4 methodology). I use CI mostly on PHP4 so always use v4 syntax, as a result this ultimately comes down to a PHP4 vs. PHp5 battle - which is a little unfair.

Having bitched about PHP4 in the past I will say that CI does have quite nice syntax with logically named libraries and rich, inclusive helpers; it makes the best of what it is given.

Unfortunately so does K2 and on top of it is puts more helpers, more 3rd party options, has method chaining (down to PHP5 I know.. but still) and replaces the load functions with a more PHP-ish style syntax (I love it!).

I also want to comment on the MVC *feel* of the 2 frameworks. For me CI makes it harder to code proper MVC style, I'm not entirely sure why this is at all but K2 feels much more.. well... MVC compliant. I know this is just perception but that can be important.

I feel bad giving this round to Kohana because CI does the job really well given the constraints of PHP4. But the cleaner feel K2 gives to your controller code is killer!

R4: Features

This is also very tough. CI has been around for ages and has tons of custom code to plug into it. Kohana has very little in terms of custom content (but growing!) however it DOES have some excellent new features. One of my favourite is the ORM (and I'm glad to see the development of this being pushed onwards for v2.2).

R4 has to go to K2 again simply because they have drawn on the good bits of CI, improved on the bad bits and added some of their own initiative / ideas.

R5: Community

For now this goes to CI (finally!), the CI community is large and excellently supported. K2's on the other hand is a little, umm, elitist. This doesn't affect me but it does piss me off a bit (I do like to think of myself as an advocate of programming for all) when I see some of the comments on the forum.

I *get* the idea: K2 is a framework aimed at commercial level and high powered development - which is why I like it so much. But I don't get why others shouldn't feel welcome.

Conclusion

Well it looks like I'm a huge K2 advocate. And you'd probably be right. I love fresh new things and Kohana is pushing the boundaries of MVC frameworks in cool and exciting directions. Not only that but it really IS a developers framework - requiring you to get down and dirty when coding. In terms of the code it produces (or rather that I produce on it) things are much cleaner, easier to follow and make more sense.

That said I won't write CI off completely; I will still use it for sites where PHP4 is the only option and I will advise newer programmers to start off there. At the end of the day it is a wonderfully lazy (if a little boring :P) way to code up a site (drag and drop modules). I also think it is a good place for new comers to learn MVC, advanced PHP and so forth: simply because the community and documentation is there for support.

In the fight (sic) Kohana has had the huge advantage of originally being a fork of CI. Pretty much all the major problems still faced by CI developers were addressed with the version 2 rewrite of Kohana. The only fall down for K2 at the moment is it's slight feel of elitism (even if that is just a perception) - if they lose that and gather a few more community members it should sky-rocket. Things are bright for the future.

Really I think K2 is THE framework (or has the potential to be) for serious programmers. Ultimately for one reason and one reason alone: it is FUN to code for. And that, for me at least, is the most important thing.