Search code examples
phpcodeigniterglobal-scope

application wide classes for codeigniter


I'm starting to use codeigniter for the first time and starting to plan out the coding structure.

I have a number of 'objects' which are referenced on a regular basis throughout the applications: user, article, photo, comment, forum topic, etc. These objects will do common functions like get/set specific details about a user, article, photo, comment, topic etc. This stuff is generally referenced on pretty much every controller at one point or another.

Where is the correct/best practice way to store these and how?


Solution

  • That's exactly how MVC works...

    Sounds like you'd create models/libraries for each of your business objects and then either use the config->autoload to include them or load them in your core controller class (application/core/MY_Controller).