How to get all routes in Laravel App?

10-Apr-2023

.

Admin

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...

#Laravel

#Laravel 6