Formerly titled My First Experiences with Kohana.
A new project at work had me and my business partner talking at length about which PHP framework to use. We had several discussions over it, and looked at lots of comparisons. It came down to Zend Framework 2, CakePHP, Symphony 2, and Kohana. We went with Kohana because of its easy learning curve, and the flexibility that it had in getting out of the way and letting us code what we needed. It seemed to provide all the functionality of a framework that we wanted, without forcing us to use strange nomenclature or paradigms.
I have now used Kohana for a week, and really do like it. There are some things that other frameworks did better (Zend Framework 1 and 2 being the ones I am most familiar) but so far it seems very capable.
One of the things that I like is that it provides a HMVC architecture. Many are familiar with MVC (Model-View-Controller), but HMVC (Hierarchal-Model-View- Controller) takes that a step further by allowing nested MVC pieces. I learned a lot about it at this post: Scaling Web Applications with HMVC which has a fantastic diagram that shows this well: 
Within my web-app this means that while working with one particular action I can call another action and insert it. Oddly enough I found the documentation on this a little sparse for Kohana 3 (seems to be a problem with any framework), and it took me some playing around with it to get it right.
Lets assume I have a controller class, Foo and inside that I have an action, bar:
Class Controller_Foo extends Controller { public function action_bar () { //perform some logic here } }
Normally all that would be passed to the view would be the results of that action. With HMVC I can call other actions within this one, and pass everything. For example:
Class Controller_Foo extends Controller { public function action_bar() { //preform some logic $other_foo = Request::factory('foo/otherfoo')->execute(); $view = View::factory('foo/bar'); $view->bind('other_foo', $other_foo); $this->response->body($view); } public function action_otherfoo() { //have some logic. $view = View::factory('foo/otherfoo'); $this->response->body($view); } }
In the previous code I have two actions, that are complete with their own views (and presumably model calls in the logic), and I can nest one inside the other. This will take the complete view from otherfoo, and place it in the response from the bar action under the variable $other_foo. All I have to do in the view is echo out the variable.
One caveat with this: if using templates the entire template is returned. I couldn't figure out for the longest time why my JS files, and page title were being repeated on the page. Then it hit me, I was pulling in the entire template with each internal call. I then put all the actions that I would want to call within the program itself into a different controller, that did not extend the template controller and Presto! I had both requests returned with only one call to the server.
Where I see this being handy is making truly reusable code. In my case, I am having the results of frequently used database calls (specifically listings by user or cemetery) so that I can call this same code and get the results in multiple places. Another is going to be a user dashboard to show several things, a login form that can be used in multiple places, or sidebars that may show various information depending on the user.
I am sure that I will post more about Kohana in the future. I have two big projects that will be using it.
My best, Will--




OpenVPN is a great open source VPN solution that we use at work. With ubuntu I just go to the terminal and as root run openvpn with my .conf file or I would set up a VPN connection with NetworkManager and just connect. In Mac OS there is a very eligant solution with the use of Tunnelblick. Seems to be more fickle with configuration file options, and there are some more steps in setting up a connection. Otherwise there is a simple connect on demand option that keeps things going smoothly.
Recently I have been just using Mac OS instead of some flavor of Linux for my computing needs. With the announcement of the latest edition of the Mac OS X series I eagerly watched for the release of Lion. I followed all the predictions of it being released on the 14th, then when that didn't happen it was to be the 15th, because the last 3 releases where on a Friday, then it was to be on the 19th because Apple was releasing their financials. It was like waiting for Harold Camping's rapture. On the 20th when it was released I waited for it to be a hoax, and so I didn't upgrade till the 21st.






