Why I Like Kohana

And now back to the regularly scheduled programming referenced in my very first post

Kohana is an HMVC PHP5 framework.

I like that it’s lightweight and fast, but also has sufficient features included (or easily added) to build fully-functional web applications.  Additionally (though I know it is kind of dumb), its coding conventions appeal to me 1; they’re actually one of the reasons I chose to pursue Kohana versus another PHP framework (and there are MANY 2 as I’m sure you’re aware).  My adventures in WordPress have forced me to accept the required brace style and Yoda conditions, though I still find them annoying.  Kohana, on the other hand, features such winners as the following:

1) Curly brackets that reside on their own lines (except in class declarations):

// Correct
if ($a === $b)
{
...
}
else
{
...
}

// Incorrect
if ($a === $b) {
...
} else {
...
}

2) Use of AND and OR (not && and ||) and elseif (instead of else):

// Correct:
if (($foo AND $bar) OR ($b AND $c))
 
// Incorrect:
if (($foo && $bar) || ($b && $c))

// Correct:
elseif ($bar)
 
// Incorrect:
else if($bar)

3) under_score naming (which, to be fair, WordPress mandates as well):

// Correct:
$foo = 'bar';
$long_example = 'uses underscores';

// Incorrect:
$weDontWantThis = 'understood?';

Clearly there’s been some turmoil (semi-)recently, concerning the future of the framework, but the fact that shadowhand has continued to be involved makes me feel confident the framework will continue to be maintained.  Which is good, because I like it and intend to use it for the foreseeable future until a compelling reason to go elsewhere emerges.

While it is argued by some (particularly those who have worked with it the longest 🙂 ) that Kohana is intuitive, the loudest criticism you hear condemns the lack of comprehensive documentation.  The official documentation is solid, I think, in many areas, though it doesn’t take long for one to find the holes containing placeholders.

Over the years, individuals have put up wikis, code snippets, and tutorials of varying length, completeness, and standards adherence.  Many have disappeared and several of those that remain have been unchanged and still reference old versions of Kohana where constructs and syntax differ considerably from the current (3.3) release.

When I first started using Kohana the lack of documentation frustrated me as well.  I made do by cobbling together concepts I picked up from the official documentation and the various developer-created sites described above, refining my coding approach as I learned more.

One of my aims with this blog is to add to the collective knowledge by posting my own code and soliciting feedback on it.  I am hoping that through learning new techniques and questioning things along the way, all of our code will improve.

  1. About the only thing I don’t like about the Kohana conventions are the string concatenation conventions (e.g. ‘This ‘.$is.’ what the convention mandates!’; ‘But I ‘ . $much_prefer . ‘ this for ‘ . $readability).
  2. Laravel appears to be a clear leader these days.
10

Leave a Reply

Your email address will not be published. Required fields are marked *