dannyvankooten/PHP-Router — Issue #6: Wildcard support
Author: AlexandraK
Created: 2012-02-27 11:54:35+00:00
State: open

It's not an issue, but it would be a good feature support. Sometimes you want to map an infinite set of paths to a controller, like:

`/site_section/*/`

So all requests to URLs that start with `site_section` should be attached to the given controller.

I've implemented this by changing `getRegex()` to search for wildcards before it does the preg_match:

$url = $this->url;
if(($match_all = strpos($url, '*')) !== false)
$url = substr($url, 0, $match_all).'(.+)';

preg_match...

Then in the match() method, after a match is found add the next path parts as parameters:

if((strpos($route->getUrl(), '*') !== false) && isset($matches[1]))
$params['path'] = trim($matches[1], '/');

I'm sure there's a better way, but this is the idea :)
Thanks for the great class!