I have many routes declared in my slim application. Some of these have route parameters
$app->get("/:user/profile",function($user) use($app){ ... });
$app->get("/test/:id",function($id) use($app){ ... });
For example if I call:
http://myhost/test/1
It is suitable for both routes, then the declaration order is very important! Is there any way to give priority to static router from parametrized?
@Tobia i hope want to this(for slim framework 2):
whenever if you have two routes in a file and you think that your two routes can be same URI at the time of calling So in that case use pass()
A route can tell the Slim application to continue to the next matching route with the Slim application's pass() method
for your above case make some condition, try this like:
$app->get("/:user/profile",function($user) use($app){
if($user == "POSSIBLE VALUES"){ // make condition that can be found in the $user parameter
}
else{
$app->pass();
}
});
$app->get("/test/:id",function($id) use($app){
});