HMansour
HMansour

Reputation: 71

CakePHP controllers and models in subdirectory

hello i was wondering how can i put my components and models in sub sub directories, lets say i have a web application that have 3 different areas (admins, users, developers) each one of them performs different actions and have a whole different interface, so i want the the admin to go to http://www.site.com/admin etc.

i have tried different soultions but none worked for me, can any one provide me with an example of how to do it.

am using CakePHP 2.1.1

Thanks in advance

Upvotes: 3

Views: 2666

Answers (3)

Hamza Khan
Hamza Khan

Reputation: 162

controller subdir way is no longer possible. And it is removed from latest version of cakephp. On the other hand you can use plugins instead of this. deizel is right you can follow what he said.

Upvotes: 0

jeremyharris
jeremyharris

Reputation: 7882

Yes, you can do this using App::build(). All it does is tell Cake where to find models, controllers, etc.

App::build(array('Model' => array('/a/full/path/to/models/')));

Now Cake will look for anything using the Model package in /a/full/path/to/models/.

Better yet, there's a plugin that does this for you automatically: https://github.com/ichikaway/AutoAppBuild

Now while this answers the original question, I think you might want to look into Routing prefixes as a better solution to your problem.

Upvotes: 8

Saanch
Saanch

Reputation: 1844

If you want to have three different interface for each role you can create three different layout and call them based on the role. Accessibility wise you can setup acl component and give authorization to the modules based on the role.

Upvotes: 2

Related Questions