How do I create a wildcard route (/something/*) in

2019-02-21 21:34发布

How can I create a route like /something/* where * could be one or mode 'subfolders'? (Using Silex framework)

For example:

/something/foo

or

/something/foo/bar

The purpose: I need to replicate a Webservice and send a POST request to another URL changing 2 $_POST parameters and give it returns back. But it can have one or mode parameters after /something.

标签: routes silex
1条回答
beautiful°
2楼-- · 2019-02-21 22:05

The trick is to overwrite the default regex for a url parameter, that doesn't match /:

$app->post("/something/{the_rest})", function () {
    // do stuff
})->assert("the_rest", ".*");
查看更多
登录 后发表回答