When you name a controller it is usually something along the lines of Blog
When you name a model it is usually along the lines of Blog_model
When you name a library it is usually along the lines of Blog_lib
Then when you load either a model or a library you load them through
$this->load->model('blog_model') or $this->load->library('blog_lib')
Then you access them through
$this->blog_model->do_something() or $this->blog_lib->do_something()
Because if this you cannot have e.g. your models and controllers and libraries having the same name.
Now I am wondering why Code Igniter does not allow you to access them through e.g.
$this->load->model('blog'); $this->model->blog->do_something()
Which to me is a lot nicer.
Is this a Code Igniter restriction, or is this a restriction in because of PHP?
I.e if I felt the urge, could I modify code Igniter to do this, or would I still run into cannot redeclare class blog… type errors?
If this is the case could Code Igniter not be modified to allow you to name your libraries blog_library and blog_model but then the loader strips off the _model and _library when you access it?
I dont think this is a restriction in PHP. Its how CI is designed. But it is surely possible to modify the core files espeiclaly that of the loader class to achieve what you want but it might be a overkill. For me i find this type of system really easy to work with and the code is easily understandable at a later point of time.