CodeIgniter: "Unable to load the requested class"

StackOverflowNewbie picture StackOverflowNewbie · Nov 6, 2011 · Viewed 116.3k times · Source

On my WAMP box, I did the following:

  1. Added a file called /application/libraries/Foo.php
  2. Foo.php is a class, and it's name is Foo
  3. In /application/config/autoload.php, I added $autoload['libraries'] = array('foo');

Everything works fine. When I upload to my LAMP box, I get the following error:

Unable to load the requested class: foo

Permission of /application/libraries/Foo.php is 0755. Owner is the same as the rest of the CI files. Taking foo out from autoload makes the problem go away.

Any ideas what might be wrong?

Answer

evan picture evan · Nov 6, 2011

In Windows, capitalization in paths doesn't matter. In Linux it does.

When you autoload, use "Foo" not "foo".

I believe that will do the trick.

I think it works when you take it out of autoloading because codeigniter is smart enough to figure out the capitalization in the path and classes are case independent in php.