2017-04-03 62 views
-5

请帮助我,如何在php sh-service框架中创建自定义路由。如何在sh-service框架中创建动态路由

+1

请仔细阅读[我可以问什么议题有关(http://stackoverflow.com/help/on -topic) 和[如何提出一个好问题](http://stackoverflow.com/help/how-to-ask) 和[完美的问题](http://codeblog.jonskeet.uk/2010/ 08/29/writing-the-perfect-question /) 以及如何创建[Minimal,Complete and Verifiable example](http://stackoverflow.com/help/mcve) – RiggsFolly

回答

0

试试这个:

$app->get('/name/:firstname',function($app,$req,$res){ 

    $res->json($req->firstname); 

} 

这是为我工作。

+0

是的,你说得对。 – sundar

0

非常感谢你为我工作。

试试这个格式:

$app->get('/name/:firstname',function($app,$req,$res){ 

    echo $req->firstname; 
} 

不要尝试这种格式:

$app->get('/name/{firstname}',function($app,$req,$res){ 

    $res->json($req->firstname); 
}