Reputation: 58
How to organize controllers under /app/controllers
in sub-
folders in CakePHP? I want to create a folder like admin
inside the controllers folder and I want to create some controller related to admin. If it is possible, then how can i call a controller from a sub folder?
Upvotes: 1
Views: 1952
Reputation: 7575
You need to re-think your application structure. Cake has something built in called prefix routing that you should probably be using.
This is also available in 1.x
Upvotes: 1
Reputation: 1289
You can use App::build() to let CakePHP know for additional packages/configurations.
App::build(array(
'Controller' => array('/path/to/controllers', '/next/path/to/controllers')
));
Upvotes: 2
Reputation: 34837
You can't alter the CakePHP file structure "just like that". It would require serious modification of the core to achieve this, but there is almost never a good reason to do so. If you properly follow the naming conventions, everything should be easy to locate.
What you could do (that is still following conventions and comes close to what you're looking for) is create a plugin for all your admin related tasks and then you can put all that logic under app/Plugin/plugin_name/Controller
instead. That way it has it's own place, although you will need to load the plugin from you main application for this to work.
Upvotes: -1