I was have been trying to create a new controller class in Code Igniter and when I try to extend CI_Controller I get the following error:

Fatal error: Class ‘L_Controller’ not found in D:\xampp\www\com\mysite\application\controllers\example.php on line 2

The standard error if of the syntax : Fatal error: Class ‘‘ not found in on line [n]


If you extend a system/core class then it goes in application/core
If you extend a system/libraries class then it goes in application/libraries

I had done this, however CI could not find my controller when implemented: Below is my controller and calling file.

I also found that CI did not like me having more then one custom sub-classed controller? Need to spend more time one day researching why this is so?




Well basically in application/config there is a section as follows:

As we can see the subclass_prefix is set to MY_, so by naming my controller starting with ‘My_’ I can implement a subclass of CI_controller.

For example:

class MY_Controller extends CI_Controller {

instead of:

class L_Controller extends CI_Controller {

Note: do not forget to name your file the same name as the controllers class name

Leave a Reply