PHP MVC Frameworks – Part 2

As I’ve already posted a while back, I’ve been heavily using a PHP MVC framework called CodeIgniter. While I have to admit that CodeIgniter made my life really easy, quickly building web applications in a very organized fashion – it’s somewhat non-rigid form made it really easy for me to do something really funky stuff – completely breaking the rules of proper MVC development.

About a month ago, while at AstriCon 2008, I had a chance to sit down with Philippe Lindenheimer (of FreePBX fame), and we had a chance to discuss different frameworks. While I brought up CodeIgniter, Philippe indicated that CodeIgniter suffers from a few flaws and also indicated to me a derivative of CodeIgniter, which according to Philippe surpassed CodeIgniter – technology wise that is. The framework’s name in dubbed Hohana ( – which according to Philippe was better than CodeIgniter.

Shortly after coming back from AstriCon, I decided to take a look at Kohana – who knows, maybe I’ll like it?

So, unlike CodeIgniter, the Kohana set of requirements is lightly more advanced than CodeIgniter, mainly, the requirement to use PHP version 5.2 and upwards (made vanilla type CentOS unusable – but Mandriva worked really nice). Unlike CodeIgniter, the people behind Kohana made it both rigid and readable at the same time. What does that mean? in general, PHP suddenly acts like a real programming language, for example, the following loop simply didn’t work in Kohana:

foreach ($items as $key=>$value) {
  $output .= "Key: ".$key." => ".$value."<br>";

The above code simply failed, with a clear error message indicating the that “$output” variable wasn’t previously used/defined, and that the structure is basically in poor programming taste. OK, so no more short hand PHP with Kohana, it actually made the code a bit more organized and readable at the end.The nice thing are the error messages, that clearly indicate to you what the problem is. If you are missing a view or a class definition, Kohana will scream out loud, not letting you continue on your way forward.

The one thing I really like about Kohana is the ability to cascade views. Cascading views means that each view is actually an object, while a view may contain additional view, as child objects. This ability allows for very organized, usable, readable view code to be written – in addition, to being able to separate AJAX calls in views to specific files and objects, making your initial view really small and tight – NICE!

All in all, a nice framework to work with and I admit that I got to like it. Let’s try to see what mileage I’ll get from it.

Leave a Reply