/application/core/MY_Controller.php - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: /application/core/MY_Controller.php (/showthread.php?tid=63470) |
/application/core/MY_Controller.php - Rashid - 11-03-2015 Hello, what if I need two (or more) different MY_Controller classes in a core folder? CodeIgniter allows creation only one "extended" version? I tried PHP Code: class MY_AuthController extends CI_Controller RE: /application/core/MY_Controller.php - Martin7483 - 11-03-2015 You just create a single MY_Controller.php file and place your required classes in this file. I have a MY_Controller.php which has a WEBSITE_Controller class and a ADMIN_Controller class RE: /application/core/MY_Controller.php - orionstar - 11-03-2015 You should create an autoload function (spl_autoload_register) which can load any base controller. RE: /application/core/MY_Controller.php - InsiteFX - 11-03-2015 Here is the autoload method: PHP Code: /* RE: /application/core/MY_Controller.php - kenjis - 11-05-2015 Using `require` in MY_Controller would be okay. PHP Code: <?php RE: /application/core/MY_Controller.php - CroNiX - 11-10-2015 Here's an old, but still applicable read: https://philsturgeon.uk/codeigniter/2010/02/08/CodeIgniter-Base-Classes-Keeping-it-DRY/ |