Hello everyone,
I'm working on a Laravel application (currently on a version identified as Laravel 12, which I understand follows the structure introduced in Laravel 11, especially regarding the configuration in bootstrap/app.php).
I want to be able to explicitly check the full list of middlewares applied to each of my routes, including both the framework's default middlewares for groups, API, and web (e.g., SubstituteBindings, ThrottleRequests, etc.) and any custom middleware I've added.
I've tried using the php artisan route:list -v command. The output I get for my API routes is similar to this:
GET|HEAD api/v1/quizzes ................................................................................... api.v1.quizzes.index › Api\V1\QuizController@index
⇂ api
GET|HEAD api/v1/quizzes/{quiz} .............................................................................. api.v1.quizzes.show › Api\V1\QuizController@show
⇂ api
I understand that the ⇂ api symbol indicates that the API middleware group is being applied to these routes. However, this output doesn't explicitly break down all the individual middlewares that make up that API group (including the framework's defaults and any I may have added).
In previous versions of Laravel, or with certain configurations, I recall that route:list -v (or using the --columns option when available) provided a more detailed listing of each applied middleware class.
My configuration in bootstrap/app.php to add a custom middleware to the API group is:
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
apiPrefix: 'api',
)
->withMiddleware(function (Middleware $middleware) {
// Alias para mi middleware
$middleware->alias([
'validate-jsonapi-headers' => \App\Http\Middleware\ValidateJsonApiHeadersMiddleware::class,
]);
// Añadiendo mi middleware al grupo 'api'
$middleware->api(append: [
\App\Http\Middleware\ValidateJsonApiHeadersMiddleware::class,
]);
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
My questions are:
-
Is there any other option or command in Laravel 11/12 that explicitly shows all middleware (classes or aliases) applied to a specific route, including those that are part of the default API or web groups?
-
If the route:list -v output I show is what I expect for these versions, is there a programmatic way (e.g., by accessing the router or routes collection) to obtain this detailed information for debugging or auditing purposes?
-
Has the way route:list -v presents this information changed in newer versions of Laravel?
I know I can rely on the framework applying the defaults, but for debugging and to have a full understanding of the execution stack, it would be very helpful to be able to see the explicit list.
Any help or clarification would be greatly appreciated!
Thanks in advance.