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

get routing link by controller and action

Hello everyone.

I have a defined route like:

$router->add(
    "/login",
    array(
        "controller" => "auth",
        "action"     => "login"
    )
);

is it also possible to get the routing link by controller and action? that i have something like this: $route->getRouteByParams(array('controller'=>'auth','action'=>'login')); and i will get back

/login

Thanks you very much for your help. Patrick



85.5k

$router->add("/posts/{year}/{title}", "Posts::show")->setName("show-posts");

$this->response->redirect(array('for' => "show-posts"));
...
$this->response->redirect(array('for' => "show-posts", 'id' => $someId));

?

https://docs.phalcon.io/en/latest/reference/url.html#generating-uris

$router->add(
    "/login",
    array(
        "controller" => "auth",
        "action"     => "login"
    )
)->setName("login");

$this->url->get(
    array(
        'for'   => 'login',
    )
);