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

Camelize action

Hello,

I'm trying to access an url like 'www.example.com/controller/some-action' I'm using an event beforeDispatchLoop but is working only for 'www.example.com/controller/some_action' and as action it finds the default one 'index'. Seems like the router doesn't recognise it as an action.

$eventsManager->attach("dispatch:beforeDispatchLoop", function($event, $dispatcher) {
    $dispatcher->setActionName(Text::camelize($dispatcher->getActionName()));
});

Thanks



16.0k
Accepted
answer

I disabled the default routing behavior, defined the routes manually and now is finally working.