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.

[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.



53.3k
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.