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

[solved] Route with no action causing cyclic routing

Hi all,

I want a route of "/store/tickets/" to be routed to:

Controller: 'store' Action: 'index' Params: 'tickets'

I'm adding the route like this:

$Router->add(
        "/store/:name/",
        [
             'controller'   =>  'store'
            ,'action'       =>  'index'
            ,'params'       =>  'name'
        ]
    );

And my StoreController looks like this:

<?php
class StoreController extends \Phalcon\Mvc\Controller{
    public function indexAction($name){
        echo $name;
    }
}

I know I've misconfigured something, but I just can't seem to wrap my head around how to fix it. Any insight would be welcome.

Try

$Router->add(
    "/store/:name/",
    [
       'controller'  =>  1
      ,'action'    =>  'index'
      ,'params'    =>  2
    ]
  );

Thanks @JimmyChandra, but that didn't work. I changed the 'controller' to "store" as well - that didn't work either.



125.8k
Accepted
answer

The cyclic problem was due to the fact I had a listener on my dispatcher that routed to "route404" if the page wasn't found. However, I didn't have a controller action associated with that route, so it triggered a 404, etc.