Get a list of registered route paths

In this session, we will discuss about how to get a list of route paths that are registered. Routes::getRoutes() is a method that can be used. This will return an object with routes information and resources. It returns the RouteCollection. You can get path information using getPath() on the route.

For Laravel 4

$routeCollection = Route::getRoutes(); 

foreach ($routeCollection as $value) {

    echo $value->getPath();

}

For Laravel 5.4

$app = app();

$routes = $app->routes->getRoutes();

return view ('Admin::routes.index',compact('routes'));

//view

<table id="routes-table" class="table table-bordered table-responsive">

       <thead>

                <tr>

                    <th>uri</th>

                    <th>Name</th>

                    <th>Type</th>

                    <th>Method</th>

                </tr>

       </thead>

       <tbody>

                @foreach ($routes as $route )

                    <tr>

                        <td>{{$route->uri}}</td>

                        <td>{{$route->getName()}}</td>

                        <td>{{$route->getPrefix()}}</td>

                        <td>{{$route->getActionMethod()}}</td>

                    </tr>

                @endforeach

        </tbody>

</table>