Can libraries have models and controllers? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Can libraries have models and controllers? (/showthread.php?tid=61361) |
Can libraries have models and controllers? - mdixon18 - 04-10-2015 Hello guys! Let's say you have a library called auth, this sits in: PHP Code: application/libraries/auth/auth.php Now, this is the library class which you can obviously load by doing: (which works perfectly) PHP Code: $this->load->library('auth/auth'); Now, can I have some folders in this library: PHP Code: application/libraries/auth/models With these folders Is it possible to load a model that is inside the models directory? I just want to keep my files together without having to put all my models in the models folder. As I would like to keep them within the library. This way inside auth.php maybe I could do: PHP Code: $CI->load->model('auth_model'); which is located in: PHP Code: application/libraries/auth/models/auth_model.php I'm hoping there is a way to do this, let me know thanks Matt RE: Can libraries have models and controllers? - silentium - 04-10-2015 As far as I know there is no way of accomplishing what you want. You will have to put your controllers and models in the regular folder. Doing that is very common for libraries, an example is Ion Auth that include a model, controller and more. RE: Can libraries have models and controllers? - ciadmin - 04-10-2015 If you didn't want controllers like that, you could use packages. Specifically what you ask for sounds like "modules" or HMVC, and there are a number of thread on those topics here. |