Home Laravel How to get all routes in Laravel Application?

How to get all routes in Laravel Application?

by Shahriar Sagor
How to get all routes in Laravel Application

Hi Dev’s, Today now in this blog I will show you how to get all routes in laravel application. When we need to fetch all routes also with name and url properties then we can use getRoutes() method in php laravel 8 application.

We can use Route facade also with getRoutes() method for getting all the list of routes. Now we can do this simply and easily to get all routes also with route name, prefix, url properties and also path.

If we want get all routes then we can use “Route::getRoutes()” example as like as 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 []

Now by using bellow command to get route list in command prompt.

Example 2

php artisan route:list

So perform above command to get list of all routes in command prompt.

Read Also : Add Charts Using Highcharts In Laravel 8

Thanks for read. I hope it help you. For more you can follow us on facebook.

close

You may also like