We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Getting module name in controller

Is there a smarter way than exploding the namespace to retrieve the currently active module in an environment which uses :module/:controller:?



98.9k
Accepted
answer

You can access the router to get the module that was routed:

$module = $this->router->getModuleName();

Hi, Please help me: How to getting module name in a class custom helper. I tried the code below but failed:

$router = $this->getDI()->get('router'); echo $router->getModuleName()