CodeIgniter v4.0.2: Current class and method names |
How can I fetch the names of the currently displayed controller class and the method?
Found a solution:
Can be used in helpers too. PHP Code: $router = \Config\Services::router();
You want the Router class, and the following methods: contrrollerName(), methodName()
You can get it directly from the service as well: $controller = services(‘router’)->controllerName()
|
Welcome Guest, Not a member yet? Register Sign In |