Kohana 3.1 Controllers in subfolders in the controller folder

I need to create sub folders for my controllers for easy management and troubleshooting. I need to have controller /, controller / administrator, controller / user / view settings. I tried to create a controller in controller / admin / createuser from http: // mydomain / admin / createuser but that doesn't work.

Anyone with any hints on this?

Do I need custom routing?

0


source to share


1 answer


You will need to configure Route to catch / admin / and look for a "directory" called admin, not a "controller file" called admin. Then your createuser parameter should ideally be in a "custom" controller, so "createuser" will be an action in your custom controller


Notice the "directory" declaration - app / bootstrap.php

Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')
  ->defaults(array(
    'directory' => 'admin',
    'controller' => 'user',
    'action' => 'index',
));

      




Then in your controller you need to use underscores for each directory '/' in the class name - app / classes / controller / admin / user.php

class Controller_Admin_User extends Controller {

  public function action_createuser()
  {
    ..your code
  }

      

+1


source







All Articles