Hey there! Since you are here, you may be interested in my book "Advanced PHP Strings: Text analysis, generation, and parsing via. Laravel" which covers parsing text, manipulating strings, managing character encodings, and much more.
The book contains over 700 pages of detailed dicussions from the Laravel string helpers to writing a Gherkin and Blade parser.
The route:list
command can be used to show a list of all the registered routes for the application. This command will display the domain, method, URI, name, action and middleware for the routes it includes in the generated table.
The following example demonstrates how to use the command without any options:
php artisan route:list
It will generate a table similar to the following output (the exact table entries will depend on the registered routes).
The routes table can be filtered by using the various different options that the command defines. The following table lists and describes each of the various options the command supports. Some of the options support user supplied filters, which are denoted by the <TERM>
appearing in the options name. Replace <TERM>
with the value to filter by when running the command.
Option Name | Description | Default Value |
---|---|---|
--method=<TERM> |
Filters the routes by method. | None |
--name=<TERM> |
Filters the routes by name. | None |
--path=<TERM> |
Filters the routes by path (URI). | None |
--reverse |
Reverses the order the routes are displayed in the table. | None |
-r |
Reverses the order the routes are displayed in the table (shortcut to --reverse ). |
None |
--sort |
The column to sort by. Accepted values are host , method , uri , name, action or middleware . |
uri |
The following examples demonstrate the effects of the various different options.
Filtering the routes by name:
# Filter the route list by name.
php artisan route:list --name=account
After the above command has executed, a table will be generated that only contains routes that have account
in the name
column:
This same process can be repeated for the --method
and --path
options:
# Filter the route list by URI.
php artisan route:list --path=account
# Filter the route list by method.
php artisan route:list --method=GET
The filters can be combined; results will be aggregated using "and" logic. The following command:
php artisan route:list --path=account --method=GET
can be interpreted as "find all routes that contain account
in the URI and contain GET
in the method."
The following examples demonstrate how to call the command with the various other options:
# Filter the routes and display them in reverse order.
php artisan route:list --method=GET --reverse
# The following is equivalent to the previous example.
php artisan route:list --method=GET -r
# Filter the routes and sort `name` column.
php artisan route:list --method=GET --sort=name