-->

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

2019-02-21 21:54发布

问题:

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.

回答1:

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", ".*");


标签: routes silex