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

How to get url parameters

Hi guys,

How can I get id value in this URL example


the id value is 3 and i'm using a router

$router->add("/delete/id/:params", array( 'controller' => 'index', 'action' => 'delete', 'id' => 1, 'params' => 1 ));

to generate that URL, and also how can i access that value in a update controller

Many thanks,


I think it's something like this:

in router:

$router->add("/delete/id/([0-9])", array( 'controller' => 'index', 'action' => 'delete', 'id' => 1 ));

in Controller:

$id = $this->dispatcher->getParam("id");

edited Sep '15

this is like

            "controller" => "index",
            "action"     => "update",
            "id"       => 1, // ([0-9]{4})
            rest of it..

you dont need to have \id\ you can either remove it or getting it as first parameter and the value as second parameter