Kohana controllers in subdirectories

To use a controller inside of a subdirectory inside of Kohana, this is how you do it:

  1. Create a subdirectory inside of the controllers folder (.e.g ‘forms’)
  2. create a controller file and name the class inside of it appropriately (e.g. ‘contactus.php’ and ‘Class Controller_forms_contactus extends Controller_Template’)
  3. create the correct route in your bootstrap.php file. Place it above any other routes:
   Route::set('forms/contactus', 'forms/(/(/))')
          'directory'  => 'forms',
          'controller' => 'contactus',
          'action'     => 'index',

By darylchymko

Code Wrangler and ultrarunner

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s