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

setDefault*() name conversions bug?

I'm confused with name conversions. If I allow default routes and try open, for example, error/not-found router matches ErrorController/notFoundAction, when i'm open error/notFound, it's also math ErrorController/notFoundAction, when i'm open error/not_found it's throw exception with message that action not found on error controller. It's somehow not clear. Why use two variants of name conversion. When i'm try to set default action/controller at router class, i'm was surprised.

$router->setDefaultController('error'); // converts to ErrorController
$router->setDefaultController('error-test'); // converts to ErrorTestController
$router->setDefaultController('error_test'); // converts to ErrorTestController
$router->setDefaultController('ErrorTest'); // converts to ErrortestController
$router->setDefaultController('errorTest'); // converts to ErrortestController

Is not so as from uri. Okay, look at action conversion: Error controller contains

public function notFoundAction() { }
$router->setDefaultAction('notFound'); // all ok
$router->setDefaultAction('not_found'); // not converts, and throw exception
$router->setDefaultAction('not-found'); // not converts, and throw exception

Perhaps it makes sense to use a single format conversion across the framework? For example underscored to camelcased ? my_error_cotroller -> MyErrorController my_not_found_action -> myNotFoundAction https://localhost/my_error_cotroller/my_not_found_action -> MyErrorController/myNotFoundAction



98.9k

This is not a bug, it's the intended behavior, we can't change that because that would break the current applications



98.9k