I had a very odd bug using codeigniter. Just an overview: I started doing the development of a web application on a Windows environment. I installed wamp, and that was my dev server. During the development phase everything worked fine. I didn’t have any problem regarding codeigniter configurations.
Once the development phase was finished, it was time to move to production. We decided to host the application on a2 hosting. We uploaded the application to the server, everything seemed to be working, when suddenly we discovered that the default route wasn’t working. That is a BIG problem! Imagine, every time we typed www.domainName.com it would throw a 404 error. The odd part, is that on the local wamp server, the default route was working. All the configurations were right. We had the .htaccess to remap the requests. We had all the routes and the default controller defined. Everything was good.
I had a problem searching for a solution, since it would always lead me to the default controller configuration, and that’s wasn’t the problem. Realizing I wouldn’t find a solution on google, I tried to go to the codeigniter channel on IRC. Nobody there could help me, some suggested that the problem was because I did the dev on a wamp server, and the host was a lamp server. That made sense, but didn’t help me much.
I was getting really frustrated, the client wanted the website online, and I had no clue what to do.
With no other option, I sat on the computer, and told me self I wouldn’t leave until the problem was fixed. First I began changing all the configurations of the application, hoping that the problem would be there. However I wasn’t lucky enough =/
100% sure that the problem wasn’t on the configuration settings of the application, I decided to change the default controller, just to see what would happen. At first it didn’t work, the second time magically worked
Now here is the deal, as simple as this might be, comparing to all other bugs I faced using codeigniter, this was the hardest to solve it, check it out:
The default controller was set to publicUser.
The first time I changed to controlPanel and still didn’t work.
Then I changed to admin and it worked!
The problem was in the camel case name of the controllers!!
For some reason, running on wamp locally I didn’t have any problems with that, but uploading to a LAMP host the default controller wouldn’t work, but only the default controller, all the other controllers worked fine, the problem was to define a camel case named controller to the default route of the application. Of course, I changed all the controller names to lower case, just in case
I found a note in the codeigniter user-guide saying that classes should not be named in camel case convention, and rather use underscores. However, the big questions remains, why throw an error only for the default controller and only in a hosted LAMP server?