CodeIgniter Forums
how i can have a master Controller???I don't know - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: how i can have a master Controller???I don't know (/showthread.php?tid=65388)



how i can have a master Controller???I don't know - dmthangtay - 06-06-2016

I know CI has a main object that i can access using get_instance, but is it possible that run other controllers through one main controller?

we can use routing role to route all requests to Main_controller/Main_method, but in that method, how i can execute requested controllers?

wiredesignz HMVC has Modules::Run method, but is there a better way?


RE: how i can have a master Controller???I don't know - skunkbad - 06-06-2016

Create a file called MY_Controller.php and put it in your application/core directory. Inside should be a class MY_Controller that extends CI_Controller. The class constructor should call parent::__construct();

Next, alter your controllers so they extend MY_Controller, not CI_Controller.

That's it.