We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

The group of routes does not contain any routes

I'm trying to define a group of routes but Phalcon raises an exception when I mount the group.

class UpdatesGroup extends Phalcon\Mvc\Router\Group {

  public function initialize() {
    // Sets the default controller for the following routes.
    $this->setPaths(['controller' => 'updates']);

    $this->addGet('/', ['action' => 'recents']);
    $this->addGet('/?tab=popolari', ['action' => 'populars']);
    $this->addGet('/?tab=recenti', ['action' => 'recents']);
    $this->addGet('/?tab=in-base-ai-miei-tag', ['action' => 'basedOnMyTags']);
    $this->addGet('/?tab=piu-votati', ['action' => 'mostVoted']);
    $this->addGet('/?tab=piu-discussi', ['action' => 'mostDiscussed']);
    $this->addGet('/rss', ['action' => 'rss']);

$router = new Phalcon\Mvc\Router(false);

$router->mount(new UpdatesGroup());

The exception message is: "The group of routes does not contain any routes" .

What is wrong?


Are you using 1.1.0?

Note that Phalcon\Mvc\Router only works with URIs but not with query strings so /?tab=popolari and /?tab=recenti are both threaded as just /

Yes I'm using 1.1.0.

Thank you for the update about the Router. It seems to me that the initialize() method is never called. Shouldn't be called automatically from the constructor?


I see the problem it's only calling "initialize" if an array is passed to the constructor :/

$router->mount(new UpdatesGroup([]));


Yes, using an empty array fixed the issue. It's a bug anyway.

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &paths) == FAILURE) {