I'm building a simple web application using CodeIgniter 3.0.3, and have run into a lot of issues regarding capitalization consistency. The CI 3.x documentation clearly states that Model files should be ucfirst and referenced using lcfirst i.e. file application/models/Foobar_model.php
, loaded using $this->load->model('foobar_model')
, and called with $this->foobar_model
. Source: Official CI 3.x User Guide.
When I follow those rules, I get the following error message Unable to locate the model you have specified: foobar_model
. Referencing the model using Ucfirst i.e. $this->load->model('Foobar_model')
and $this->Foobar_model
generates the exact same error message. I am able to resolve the issue by making my filename lcfirst application/models/foobar_model.php
while the class name inside the file remains Ucfirst. As long as I name my file lcfirst foobar_model.php, it does not seem to matter whether I use Ucfirst or lcfirst to reference it from inside my controllers.
Strangely, I have found that I need to use application/controllers/Ucfirst_controller.php
for my controllers with case-sensitive routing i.e. $route['default_controller'] = 'Ucfirst_controller';
. I receive a 404 error when trying to route $route['default_controller'] = 'lcfirst_controller';
to application/controllers/lcfirst_controller.php
.
Everything I have found on stackoverflow and other forums for CodeIgniter model and controller issues seems to involve people using lcfirst instead of Ucfirst on CodeIgniter 3.x, or using Ucfirst instead of lcfirst on CodeIgniter 2.x.
Basically my question is where is this case inconsistency coming from and how can I fix it? I want to follow standards so that others can join my project at a later point.
Other Info: I don't think that this should matter, but just in case. I am developing on LAMP on an Ubuntu machine with ext4 file formatting which is obviously case sensitive. I plan to deploy my project with Google Compute Engine running debian-7-wheezy with a HHVM stack. I am currently developing with just one partner, who is developing on a MAMP stack with non case-sensitive file formatting so he does not experience any of these issues.
Thanks everyone :~)