Strange routing behavior...


I'm new to phalcon and I'm asking myself if this behavior is "usual" - to me it looks like a bug:

 * Registering a router
$di['router'] = function() {

    $router = new Router();

    $router->addGet("/api1/:action", array(
        'module' => 'frontend',
        'controller' => 'api',
        'action' => 1
    $router->addGet('/', array(
        'module' => 'frontend',
        'controller' => 'index',
        'action' => 'index'
    return $router;

When the first route is called with correct parameters, I receive the following error mesesage:

  • Myspace\Frontend\Controllers\Api1Controller handler class cannot be loaded

Which is correct, because I expect "ApiController" to be loaded instead of "Api1Controller"(see documentation: ). Am I missing something? Can't believe routing is faulty at this level.


You have not set autoloading namespace in autoloader, may be. Autoloader can be set globally. And you have not determine action in first route also, but it's secondary obstacle.


Autloading was setup correctly. I have now added an action entry to the array (and updated the source code from my first post to reflect this), but this doesn't change anything. Autoloading is setup properly because when I change

$router->addGet("/api1/:action/$latlngPattern/$latlngPattern/$latlngPattern/$latlngPattern", array(


$router->addGet("/api/:action/$latlngPattern/$latlngPattern/$latlngPattern/$latlngPattern", array(

the proper action + controller is called (\Myspace\Frontend\Controllers\ApiController).