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 controller name and action in micro

Is there a way to get the controller name and action called in a micro app?

I currently have this in the code:

$eventsManager->attach('micro', function($event, $app) { if ($event->getType() == 'beforeExecuteRoute') {

} });



98.9k
Accepted
answer

A micro application does not have the concept of controllers. A micro application executes handlers according to a matched route. You can control access by using the uri:

$eventsManager->attach('micro', function($event, $app) {
    if ($event->getType() == 'beforeExecuteRoute') {
        if ($app['router']->getRewriteUri() == '/login') {
            // ...
        }
    }
});


1.4k

Thanks, that will be helpful with what I want to do.