Monday, June 08, 2009

I Love Kohana PHP Framework – My New Found Love

Kohana is not only my new found love when building applications with php, its also rock solid MVC (Model View Controller) Object Oriented Framework for php developers.
Just like the .NET Framework and Java SDK, Kohana can be referred to as some sort of SDK for php developers, it brings a lot of order into php codes which have been referred to as spaghetti codes for years .
With Kohana php or other php frameworks like Codeigniter, you can build your application with objects just like in Java and any other developer who knows how to use the framework will easily follow your code without asking you questions. if you ever wanted to use php in a team environment, I will ask you to consider Kohana due to the following reasons:

True Object Oriented:
Everything in Kohana SDK is an object, the helpers are objects with static methods, the libraries are all objects and you can create your own classes/objects, the views are objects (which is strange but programming wise very interesting), and of course the controllers and Models are all objects.
In other frameworks, I had never wanted to create controllers and extend them but in Kohana I realized that sometimes I have to build some ABSTRACT CONTROLLERS (I feel am back in Java), and then extends these controllers in the various sections of my website. For instance there is a Template Controller that helps developers using Kohana easily create master templates for their pages.

Best ORM in PHP:
ORM or object relational mapping is a technology where in you can map your database tables and their relationships in objects (Models) and then instantiate those models and call functions to get the data without writing SQL. In Kohana, I find ORM very easy to use and fun. Before ORM in Kohana, I tried ORM in Cakephp and Codeigniter but they all proved to be buggy or were too difficult to comprehend.

Templating made easy:
Templating is something most web developers in Africa will have to consider, it makes your life easy as a developer and makes the life of designers you work with super easy. In Kohana you create a single template.php file which can constitute the site's logo, navigation, sidebar and footer. Then fit in some variables that will change from control function to control function. This way my web apps all have one master template and just small view files that I set as variables. It makes my life easy to edit and also to change the design of the whole site in minutes. Check out the templating in Kohana at www.kohanaphp.com and you will be amazed

I8n aka internationalization:
Before Kohana I had to figure out how to hack Codeigniter to do internationalization but with Kohana, everything that appears on the screen as text you can use the i8n folder found in application/i8n and make sure you have text in every language possible. Coming from Cameroon, just like Canada we have french and english as official languages which means most of my apps have to be internationalized from day one.

PHPDOC and Code Hints, Code Completion:
In Kohana, since everything is an object, it simple means using phpdoc very well and a good IDE like Netbeans 6.5, you will get code hints and completion for both in build Kohana libraries, helpers, other classes and your own built classes. I use Netbeans 6.5 and when I code, I get a lot of speed reading the code hints and getting code completion for the functions in every helper or object I want to use. It makes my life easy and I just feel I am coding using .NET C# or Java. But other than Visual Studio, and like Eclipse, Netbeans is free and its light weight (in terms of memory consumption) and easy to install and configure to coding with php.

Those are some of the reasons I think I will go with Kohana.
Another question is:
why use php at all?
Well php is cheap for me and the server I have bought runs only php and most of my clients don't care which technology we use so we go with php. Hey with php I get to train and employ talents in the space of 6months, something I cant do with .NET or Java.

What do you think about Kohana php ?