CodeIgniter extending controller using composer not working CodeIgniter extending controller using composer not working codeigniter codeigniter

CodeIgniter extending controller using composer not working


CodeIgniter loads CI_Controller after your vendor/autoload.php file, and since you're listing them under the "files" option in your composer.json, they're included immediately as opposed to right when you need them.

That's not only what causes the error, but also beats the entire purpose of using an autoloader - if you'd be explicitly listing the includes, you might as well just require_once them.

What's common in CI, is to require or even directly declare your multiple base controller classes from inside MY_Controller.php - then you know they'll be available exactly when you need them.

But if you insist on loading them through Composer, there's a work-around - list system/core/Controller.php under the autoloaded files as well.