Search code examples
phpurlparametersroutessilex

how to get a URL in route parameter in Silex


How can I pass a URL in a Silex-app?

My given specification is:

http://mysilex.app/http://anotherurl.com

So, I would like to use it in my app like this:

$app->get('/{url}', function ($url) {
  //do awesome things with $url(=http://anotherurl.com)
  return $url;
});

Is that possible in Silex?


Solution

  • Set .* pattern for url parameter

    $app->get('/{url}', function ($url) {
      //do awesome things with $url(=http://anotherurl.com)
      return $url;
    })
    ->assert('url', '.*');