简体   繁体   中英

Slim framework v3 route conditions

in Slim v2 we had these conditionals to define routes

$app->get('/:route', function($route) use($app) {
    //Code goes here
})->conditions(array('route' => 'route1|route2|route3'));

My question is, how can I replicate this in Slim v3?
Thank you

Slim 3 uses FastRoute , so the format is: {name:regular expression conditional} .

In your case, you need:

$app->get('/{route:route1|route2|route3}', function($request, $response, $args) {
    $route = $args['route'];
    // code here
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM