0
votes

In my CakePHP 3 application I used different controllers for different parts - like so:

app/src/Controller/Admin/...  
app/src/Controller/Backend/...  
app/src/Controller/Frontend/...  
app/src/Controller/Api/...  

All templates follow the same hierarchic structure.

Now, since my application is getting more complex, I would also like to split up all model classes putting them in a similar folder structure.

So how could this be done? How can I tell the controller which table class to use by default?

1
Just to organize them? why? what are you trying to accomplish by splitting them up? I wouldn't probably even have structured your Controllers like that - cake's conventions will work just fine even if you have an immensely complicated app with 500+ models - ahoffner
Well, if I put the model classes in the same folder structure, they are not recognized - the controller always loads the models in the default directory (...app/src/Models/). I would like to split them up for a nicer and cleaner application structure. For example in the backend- and admin-area some behaviors and virtual fields are needed, which are obsolete in the frontend. Obviously maintenance and further development become much more difficult if you put everything together in one simple model. The controller structure follows cakes routing and prefixing. - Andreas
Surely your API will be using most of the same tables as your front end, back end and admin. You would seem to want to make copies of them in each folder of your structure so that you can remove the virtual fields that aren't used in each particular area? That seems like you're opening yourself up to FAR more maintenance, as any bug you fix or feature you add needs to be checked on multiple versions. - Greg Schmidt

1 Answers

0
votes

As Cakephp prefers conventions over configurations ,so if you will just follow the conventions of table,model and controllers then you do not need to worry about these things.here is link to study conventions and here is the cakephp inflector buid by Cakphp team for convention check.I will help you if find some solution for this issue