在Slim v2中,我们有这些条件来定义路线
$app->get('/:route', function($route) use($app) {
//Code goes here
})->conditions(array('route' => 'route1|route2|route3'));
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何在Slim v3中复制这个?
谢谢
Rob*_*len 12
Slim 3使用FastRoute,因此格式为:{name:regular expression conditional}.
在您的情况下,您需要:
$app->get('/{route:route1|route2|route3}', function($request, $response, $args) {
$route = $args['route'];
// code here
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1508 次 |
| 最近记录: |