[php] CodeIgniter: "Unable to load the requested class"

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?

This question is related to php codeigniter autoloader

The answer is


If you're using a linux server for your application then it is necessary to use lowercase file name and class name to avoid this issue.

Ex.

Filename: csvsample.php

class csvsample {

}

I had a similar issue when deploying from OSx on my local to my Linux live site.

It ran fine on OSx, but on Linux I was getting:

An Error Was Encountered

Unable to load the requested class: Ckeditor

The problem was that Linux paths are apparently case-sensitive so I had to rename my library files from "ckeditor.php" to "CKEditor.php".

I also changed my load call to match the capitalization:

$this->load->library('CKEditor');