Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

routes

silex

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.

like image 744
Ricardo Martins Avatar asked Jan 28 '15 10:01

Ricardo Martins


1 Answers

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", ".*");
like image 69
Maerlyn Avatar answered Oct 21 '22 05:10

Maerlyn