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 ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example