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
If you really want to, you can easily work around this limitation by relaxing the requirement on the variable. You can do that by using assert:
$app->get('/pdf/{template}/{args}', function ($template, $args) {
...
})
->assert('args', '.*')
->convert('args', function ($args) {
return explode('/', $args);
});
By making the $args
regex more permissive, it will match the rest of the string, even if it includes slashes. The param converter then splits that matched string into segments.
In general I agree with @Sgoettschkes' suggestion to use query string arguments for this. If you need highly dynamic routing with flexible segments, you're doing something wrong in most cases. And query string is usually the better fit for those params.