\$\begingroup\$

I believe you are on the right track.

The only thing that I would do different would be to add a library folder in which I would store all my common stuff like models, utility classes, helpers etc. I would also namespace everything so as to avoid collisions with any other application or piece of code out there.

My preferred app structure for your app would be as follows

app/ mail/ controllers/ MailController.php web/ controllers/ WebController.php library/ MyAPI/ models/ Users.php <- The model accessing the users table Auth.php <- Authentication Controller.php <- A master controller where all controllers inherit from Model.php <- A master model that all models inherit from Locale.php Utils.php var/ config/ collections.php db.php config.php cache/ dummy.txt metadata/ dummy.txt logs/ dummy.txt public/ index.php

Your controllers inherit from the base controller in the library folder. In that controller you can do common tasks for all collections. The same applies to the master model.