The injection of parameters is upon the names of it, you have to put the same name of parameter on the function and the string of route.
May 17, 2017
2
Level 1
Route Parameters setting problem
Hi, I had a problem about the route parameters in Lumen.
My code is
$app->get('/a/{p1}/b/{p2}', function ($p3, $p2) use ($app) {
return [$p3, $p2];
});
when I request it by curl -XGET http://localhost:8000/a/1/b/2
It print ["2","1"] not my expect result ["1","2"]
but the code rewrite to
$app->get('/a/{p1}/b/{p2}', function ($p1, $p2) use ($app) {
return [$p1, $p2];
});
It print ["1","2"], that's my expect result.
I don't know why. Is there any reason for this?
Please or to participate in this conversation.