我希望找到一种方法,用Laravel4中注册的路由路径创建一个array.
基本上,我希望得到一份类似以下内容的列表:
/
/login
/join
/password
我确实遇到了一个方法Route::getRoutes()
,它返回一个包含路由信息和资源的对象,但是路径信息是受保护的,我不能直接访问该信息.
Is there any other way to achieve this? Perhaps a different method?
我希望找到一种方法,用Laravel4中注册的路由路径创建一个array.
基本上,我希望得到一份类似以下内容的列表:
/
/login
/join
/password
我确实遇到了一个方法Route::getRoutes()
,它返回一个包含路由信息和资源的对象,但是路径信息是受保护的,我不能直接访问该信息.
Is there any other way to achieve this? Perhaps a different method?
Route::getRoutes()
返回RouteCollection
.在每个元素上,你可以做一个简单的操作来获取当前路由的路径.
每个受保护的参数都可以通过标准的getter获取.
循环的工作原理如下:
$routeCollection = Illuminate\Support\Facades\Route::getRoutes();
foreach ($routeCollection as $value) {
echo $value->getPath();
}