Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter 4 Current/Active Controller

In Codeigniter 3 is possible to get current active class and method with this code:

    $active_controller = $this->router->fetch_class();
    $active_function = $this->router->fetch_method();

Are there such functions in Codeigniter 4?

like image 426
Tsefo Avatar asked Nov 28 '25 19:11

Tsefo


1 Answers

In CodeIgniter 4

$router = service('router'); 
$controller  = $router->controllerName();  

$router = service('router');
$method = $router->methodName();
like image 174
mathan Avatar answered Dec 01 '25 17:12

mathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!