Display list of routes in Laravel application

The Laravel Artisan command that I use most often is probably php artisan route:list. But it’s not always convenient to open up a shell to run the command.

Like most things in Laravel, it’s easy to set up a route in your application to display the same route details in the browser. In your app\Http\routes.php file just add the following route.

Route::get('appRoutes', function() {
    return "<pre>" . \Artisan::output() . "</pre>";

Now, when you navigate to the `appRoutes` route in your application, such as http://localhost/appRoutes, it will display the routes just like in the shell.

And if you want to put a little bit of security around this route, such as only allowing authenticated users to execute it, just reference the auth middleware like this:

Route::get('appRoutes', function() {
    return "<pre>" . \Artisan::output() . "</pre>";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s