Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用Silex,如何从before过滤器中获取当前的 Route 对象?例如,
before
$app->before(function() use ($app) { // need to access Route for matched URL here });
我需要整个对象,而不仅仅是名称。
未经测试,但这应该可以工作。
$app->before(function(Request $req, Application $app) { $route = $app['routes']->get($req->get('_route')); });
只是好奇,为什么需要 Route 对象?