如何获得在Laravel注册路由器的路径列表? [英] How to get a list of registered route paths in Laravel?
问题描述
我希望能找到一种方法,在Laravel 4创建注册路线路径的数组。
I was hoping to find a way to create an array with the registered routes paths within Laravel 4.
从本质上讲,我希望得到一个列表这样的返回:
Essentially, I am looking to get a list something like this returned:
/
/login
/join
/password
我没碰到过的方法路线:: getRoutes()
返回的路线信息,以及资源,但该路径信息的对象受到保护,我不'T具有对信息的直接访问。
I did come across a method Route::getRoutes()
which returns an object with the routes information as well as the resources but the path information is protected and I don't have direct access to the information.
是否有任何其他的方式来实现这一目标?也许不同的方法?
Is there any other way to achieve this? Perhaps a different method?
推荐答案
路线:: getRoutes()
返回 RouteCollection
。在每个元素,你可以做一个简单的 $为route-方式>的getPath()
来得到当前的路由路径
Route::getRoutes()
returns a RouteCollection
. On each element, you can do a simple $route->getPath()
to get path of the current route.
每个保护参数可以是一个标准的吸气剂获得
Each protected parameter can be get with a standard getter.
环通是这样的:
$routeCollection = Route::getRoutes();
foreach ($routeCollection as $value) {
echo $value->getPath();
}
这篇关于如何获得在Laravel注册路由器的路径列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!