I was hoping to find a way to create an array with the registered routes paths within Laravel 4.
Essentially, I am looking to get a list something like this returned:
/
/login
/join
/password
I did come across a method Route::getRoutes()
which returns an object with the routes information as well as the resources but the path information is protected and I don't have direct access to the information.
Is there any other way to achieve this? Perhaps a different method?
use Illuminate\Support\Facades\Route;
On Laravel 5.4, it works, 100 %
if you have compiled routes like /login/{id} and you want prefix only:
I created a route that will list each route and its respective details in an html table.
You can use console command:
Helpers :
For Laravel 5, you can use artisan command
php artisan route:list
instead ofphp artisan routes
.Route::getRoutes()
returns aRouteCollection
. On each element, you can do a simple$route->getPath()
to get path of the current route.Each protected parameter can be get with a standard getter.
Looping works like this: