Params mismatch

Here is my route:

$router->addGet("/rest/:controller/{id}", array(
    "controller" => 1,
    "action" => "read"

and here is my action:

public function readAction(){
    echo $this->dispatcher->getParam('id');

When is go to rest/test/1 url it returns test instead of 1. Is it a bug?



I think this should do the trick

public function readAction($id){....


but you're right, you get here a curious behavior ....

edited Dec '14


this behavoir is because you mixing placeholder and named parameter. named parameter are parsed in an extra function with own counter i guess.

in your case you get a compilied path like that:

    "controller" => 1,
    "action" => "read",
    "id" => 1

however you should create a new issue on github.

use instead of your implementation:

// placeholder
$router->addGet("/rest/:controller/:id", array(
    "controller" => 1,
    "action" => "read",
    "id" => 2


// named parameter
$router->addGet("/rest/{controller}/{id}", array(
    "action" => "read"