Slim framework v3 路由条件
Slim framework v3 route conditions
在 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
});
在 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
});