Wallace, you can do it this way:
foreach (Route::getRoutes() as $route) {
var_dump($route->getUri());
}
The class Route
is a stab for the class Illuminate\Routing\Router
in the Laravel
.
So if you look in this class, it has a method called Router::getRoutes
. This method will return an instance of Illuminate\Routting\RouteCollection
, which is a collection of routes (Illuminate\Routing\Route
not to be confused with Router
) that you added to Laravel
.
If you want to transform the class object RouteCollection
in a array
, just call the method again getRoutes
(but this time, this method is RouteCollection
and not of Router
).
Thus:
var_dump(Route::getRoutes()->getRoutes());
You can also capture the route name using the method Illuminate\Routing\Route::getName()
.
Thus:
foreach (Route::getRoutes() as $route) {
var_dump($route->getName());
}
http://stackoverflow.com/a/23673413/5165064 take a look at
– Rafael