Is it possible to have an unknown number of arguments for a get request?
Example, this works but isn\'t ideal.
$app->get(\'/print/{template}/{arg1
The routing component does not support this out of the box as far as I know.
I looked into the code a bit and came to the conclusion that adding such a route would be difficult. The way the routing works is that each route gets registered before the matching is done, so the route has to exist. This means there can not be a "wildcard route".
I don't know if you took this into account, but you can always pass as much information as you like through "real" get parameters:
/print/template?optional1=arg&optional2=arg
This would solve your problem and would work without any modification.
Another way you could handle this is by registering a before event, looking at the request yourself and modifying it. You could for example split the whole url by /, see if the pattern matches your expected format and then put all the optional arguments into one argument with a special character spacer in between. I would not suggest this, but it is possible.
Another way of handling this is by registering your own ControllerCollection, getting the actual request and registering a route which matches the actual request in case there are optional arguments. This would be a bit cleaner I guess.
One way of solving this could be the front-end. If your request always puts additional parameters into the last parameter with a special character in between, you could read those last parameter, split it and work with that:
/print/template/arg:arg
Your could would be something like:
$app->get('/print/{template}/{args}', function ($template, $args) use ($app) {
$args = explode(':', $args);
$str = $template . " " . $args[0] . " " . $args[1];
return $str;
})
->value('template', FALSE)
->value('args', FALSE);
I would go for idea 1 or 4, mainly because 2 and 3 will be very confusing over time and appear to be not very clean.