问题
In laravel I can use the following to get the current name of the route in my blade template:
{{ Route::currentRouteName() }}
How can I do the same in Lumen?
回答1:
example:
<?php
$method = Request::getMethod();
$pathInfo = Request::getPathInfo();
$currentRoute = $app->getRoutes()[$method.$pathInfo];
echo $currentRoute['action']['as'];
?>
回答2:
I fixed this with:
list($found, $routeInfo, $params) = app('request')->route() ?: [false, [], []];
$routeName = isset($routeInfo['as']) ? $routeInfo['as'] : null;
回答3:
This is how I do it
$request->route()[1]['uses'];
来源:https://stackoverflow.com/questions/31089939/get-current-route-name