How to get a list of registered route paths in Laravel?
Route::getRoutes()
returns a RouteCollection
. 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:
$routeCollection = Illuminate\Support\Facades\Route::getRoutes();
foreach ($routeCollection as $value) {
echo $value->getPath();
}
You can use console command:
Laravel 4 as asked in question
php artisan routes
Laravel 5 more actual
php artisan route:list
Helpers (Laravel 4) :
Usage:
routes [--name[="..."]] [--path[="..."]]
Options:
--name Filter the routes by name.
--path Filter the routes by path.
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
--env The environment the command should run under.