sebdd's avatar

Is it possible to match an unlimited amount of segments in lumen?

Is it possible to match an unlimited amount of segments as one with lumen's router? (I found this for laravel).

Ex. /foo/{somekindofwildcard} would match /foo/bar, /foo/bar/baz, etc.

0 likes
4 replies
bart's avatar

I think it is something like this in Lumen:

$app->get('foo/{segments}', function() {})->where('segments', '(.*)');
sebdd's avatar

That doesn't work because lumen returns $app after calling get (which doesn't have a where method).

bart's avatar

Yeh, sorry dude. In Lumen you have to use something like this:

$app->get('foo/{(.*)}', function($expression) {
    // You stuff goes here
});
1 like
sebdd's avatar
sebdd
OP
Best Answer
Level 1

That actually didn't work either, but pushed me in the right direction. This is how I got it to work:

$app->get('/{foo:.*}', function($foo) {
    // ...
});

Please or to participate in this conversation.