CodeIgniter creating MY_Controller CodeIgniter creating MY_Controller codeigniter codeigniter

CodeIgniter creating MY_Controller


Double check the case on your class name and file name.

class MY_Controller extends CI_Controller

Notice how MY_ is all upper-case. Make sure this file is saved as application/core/MY_Controller.php, again note the case.

CodeIgniter should auto-load this file for you.

Docs: https://www.codeigniter.com/user_guide/general/core_classes.html

P.S. Check the $config['subclass_prefix'] option in your application/config/config.php file.


You don't need the autoloading functionality. Codeigniter will automatically load My_Controller as long as it's in your application/core directory.


You don't need to autoload your class, the framework will do it for you. In your case check the config file whether the subclass_prefix is 'MY_'. Eg; $config['subclass_prefix'] = 'MY_';Put your class in application/core. Make sure the class name and the file name is the same.