Practical Options for the Route List Command in Laravel

Arie Visser • October 1, 2020

laravel php

When you want to show a list of all registered routes in your application, you can use the php artisan route:list command.

The output of this command can be a bit confusing when you are working on a large application, with lots of routes, middleware etc.

For example, you might end up with a table like this:

alt text

While this shows all the data, it is difficult to read.

The compact option

The readability of the output can be improved by adding the --compact option:

php artisan route:list --compact

This will generate a table like this, with only the Method, URI and Action columns:

alt text

Filtering routes

It can also be very convenient to filter the routes, for example by the URI. You can do this with the --path option:

php artisan route:list --compact --path=api

This will only show routes containing the string "api" in their path.

alt text

Other filters you can apply are --method and --name.