How to get all routes in Laravel App?
Hi Dev,
Today I will learn you get all routes in laravel app. you need to fetch all routes with name and url properties then use getRoutes() method in php laravel 6.
you can use Route facade with getRoutes() method for getting all list of routes. you can simply and easily to get all routes with route name, prefix, url properties and path.
you get all routes then use "Route::getRoutes()" example is bellow.
Example 1
public function getRouteList()
{
$routeList = \Route::getRoutes();
dd($routeList);
}
Output
RouteCollection {#37
#routes: array:3 []
#allRoutes: array:11 [
"HEAD_ignition/health-check" => Route {#149 }
"POST_ignition/execute-solution" => Route {#148 }
"POST_ignition/share-report" => Route {#152 }
"HEAD_ignition/scripts/{script}" => Route {#153 }
"HEAD_ignition/styles/{style}" => Route {#154 }
"HEADapi/user" => Route {#205 }
"HEAD/" => Route {#206 }
"HEADdatepicker" => Route {#207 }
"HEADhome" => Route {#208 }
"HEADjquery-loadmore" => Route {#209 }
"HEADcontact-us" => Route {#210 }
]
#nameList: array:2 []
#actionList: array:10 []
bellow command to get route list in command prompt.
Example 2
php artisan route:list
perform above command to get list of all routes in command prompt.
It will help you...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial