Welcome Guest, Not a member yet? Register   Sign In
Can libraries have models and controllers?
#1
Heart 

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
application
/libraries/auth/controllers 

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
Reply
#2

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.
Reply
#3

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB