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

About the routes config ,is it the design problem?

$config = array(
    'best-url' => array(
        'pattern' => '/best',
        'paths' => array(
            'controller' => 'cate',
            'action' => 'index?cate_id=1',
        ),
    ),
    'better-url' => array(
        'pattern' => '/better',
        'paths' => array(
            'controller' => 'cate',
            'action' => 'index?cate_id=2',
        ),
    ),
    'cate-url' => array(
        'pattern' => '/cate/index/:int',
        'paths' => array(
            'controller' => 'cate',
            'action' => 'index',
            'cate_id' => '1'
        ),
    )
);

I have a requirement that ,the url map to the cate_id like /best -> /cate/index?cate_id=1,/better -> /cate/index?cate_id = 2,I don't know how to config my routes,I had solve it above,but I need it auto reverse routing when I use $url->get('for'=>'cate-url','cate_id'=>1) it can not create the url like /best or /better. How can I solve it, thanks.



98.9k

Are you disabling default routes?

// Create the router without default routes
$router = new \Phalcon\Mvc\Router(false);

https://docs.phalcon.io/en/latest/reference/routing.html#default-behavior



1.1k

Thanks your reply,the forum can reply eventually.

Are you disabling default routes?

// Create the router without default routes
$router = new \Phalcon\Mvc\Router(false);

https://docs.phalcon.io/en/latest/reference/routing.html#default-behavior