【发布时间】:2016-06-28 19:24:40
【问题描述】:
在 Slim v2 中,我们使用这些条件来定义路由
$app->get('/:route', function($route) use($app) {
//Code goes here
})->conditions(array('route' => 'route1|route2|route3'));
我的问题是,如何在 Slim v3 中复制它?
谢谢
【问题讨论】:
在 Slim v2 中,我们使用这些条件来定义路由
$app->get('/:route', function($route) use($app) {
//Code goes here
})->conditions(array('route' => 'route1|route2|route3'));
我的问题是,如何在 Slim v3 中复制它?
谢谢
【问题讨论】:
Slim 3 使用FastRoute,所以格式为:{name:regular expression conditional}。
在你的情况下,你需要:
$app->get('/{route:route1|route2|route3}', function($request, $response, $args) {
$route = $args['route'];
// code here
});
【讨论】: