Hi Guys, in this article, I will explain how to get all routes lists using getRoutes() in Laravel 5 app. we can simply get registered routes in laravel 5.6 application. we will use Route facade with getRoutes() method for getting all list of routes.
If you require to generate and get all list of routes then you can get it by using this way : "Route::getRoutes()" , Then you can simply get following thing.
Routes List
$route->getName()
$route->uri
$route->getPrefix()
$route->getActionMethod()
Now at bellow we will see full example with creation of dummy routes then we wil get list of routes. so let's add following routes in bellow web.php file.
routes/web.php
Route::get('get-all-route', function () {
$getRouteCollection = Route::getRoutes(); //get and returns all returns route collection
foreach ($getRouteCollection as $route) {
echo $route->getName();
}
});
I hope you like........
Do you like below Tutorials ?
- How to Copy File from One Folder to Another in Laravel?
- How to Move File from One Folder to Another in Laravel?
- Laravel Remove File from Storage Folder Example
- React JS Textbox onchange Event Example
- React JS Textarea onchange Event Example
- React JS Select onchange Event Example
- React JS Radio onchange Event Example
- React JS Checkbox onchange Event Example