Module Routing Not Working as Expected

Hey there,

I'm writing an API app, complete with a versioning strategy. I found something really weird happening in the routing of modules. I posted originally at stack overflow (, but I didn't get an answer, so much as I got hacks (I mean no disrespect to the help I received; I greatly appreciate the help).

Here's the problem:

  • /v1 | /v1/ - Doesn't work
  • /v1/users | /v1/users/ - Works fine
  • /v1/users/1 | /v1/users/1/ - Works fine
  • /v1/users/1/permissions | /v1/users/1/permissions - Works fine

Here's the router itself:

    $di->set('router', function () {
        $router = new Router(false);


        $router->add('/:module/:controller/:params', array(
            'module' => 1,
            'controller' => 2,
            'params' => 3


        return $router;

At this point, I was hoping to get an explanation as to why this problem exists. I can't seem to figure out why the module doesn't match to the route. The rest of the routes work fine; it's just that first one that doesn't match. I am not looking for a solution; I wanted to get a converstaion going on why this is happening, and, if it's a potential problem, maybe talk about how we could fix it.

Any guidance would be great!



you can try with groups, this is how i did it and it works for me

this is one of the phalcon's weirdness and most likely a bug; but I didn't find to be a big deal, so I got over it like many others around here.

If Izo's solution doesn't work or is not what you're looking for, you can submit a bug report