Laravel framework provides various built-in Artisan commands that can help during application development. This tutorial shows how to use Artisan command to display configured routes in Laravel 9 application.
Let's say we have defined the following route for the /test
URL:
<?php
use App\Http\Controllers\TestController;
use Illuminate\Support\Facades\Route;
Route::get('/test', [TestController::class, 'index'])->name('test_index');
The route:list
command can be used to get all configured routes in Laravel application:
php artisan route:list
By default, the route middleware is not displayed in the command output. The route middleware can be displayed by adding the -v
option to the command:
php artisan route:list -v
Output example:
GET|HEAD test ......................................... test_index > TestController@index
| web
By default, the command displays all routes, even if they are defined by third-party packages. The --except-vendo
r option can be provided when executing the command in order to hide routes that are defined by third-party packages.
php artisan route:list --except-vendor
The --path
option can be used to show routes that match the given path:
php artisan route:list --path=test
Leave a Comment
Cancel reply