Just another idiot with a blog

Kohana 3 Name Spacing with Underscores in Controller Classes

So, I’ve been working with Kohana 2.3.4 lately and its absolutely beautiful. A much improved version of what Codeigniter should have been. Now they released Kohana 3 which is similar, yet very different. One of the “gotchas” I noticed in KO3 (Kohana 3) is the auto loading of controller classes and the name spacing with underscores. Here is an example of what I’m talking about.

All underscores are converted to slashes

In Kohana 2 you could name a class with underscores and there would be no problem

now the underscores are converted to slashes

notice the Controller_ is in the front now which translates to controller/

Within the classes folder in application you notice there is classes/controllers to keep for instance a file extending off template.

So a template in controllers would need to be named defaulttemplate.php which would become Controller_DefaultTemplate, BUT if you wanted it to be Controller_Default_Template it would have to be in a sub folder called Default in controllers then template.php

Its a bit confusing in the beginning but you’ll get used to it. The entire system is a helluva improvement. Look forward to a few articles i’ll be writing on using the ORM.

Cheers,
-Wes

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon

Leave a Reply

Copyright ©2012 wessray.com
Protected by Copyscape Unique Content Validation