Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current Route object from inside $app->before filter?

Tags:

symfony

silex

Using Silex, how can I get the current Route object from inside a before filter? e.g.,

$app->before(function() use ($app) {
    // need to access Route for matched URL here
});

I need the whole object, not just the name.

like image 258
mpen Avatar asked Jan 30 '26 17:01

mpen


1 Answers

Not tested, but this should work.

$app->before(function(Request $req, Application $app) {
    $route = $app['routes']->get($req->get('_route'));
});

Just curious, why you need the Route object?

like image 69
xmarcos Avatar answered Feb 02 '26 12:02

xmarcos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!