Debugging Routes

Listing, Caching, and Debugging Routes

php artisan route:list prints each route's verbs, URI, name and action; -v adds middleware, --path, --name and --method filter, --except-vendor hides package routes, and --json feeds scripts.

The bookshop's routes without package routesShell
php artisan route:list --except-vendor
Output
  GET|HEAD   {shop}.bookshop.test/ ........................... storefront › routes/web.php:13
  GET|HEAD   admin/orders/{order} ............ admin.orders.show › Admin\OrderController@show
  ...
  GET|POST|HEAD newsletter ................................................ routes/web.php:23
  POST       webhooks/payments .................... webhooks.payments › routes/webhooks.php:7
  GET|HEAD   {fallbackPlaceholder} ........................................ routes/web.php:87
                                                                          Showing [24] routes

The domain route comes first and the fallback last, the order the router tries them. With --path=search -v, the search route gains two lines, ⇂ web and ⇂ throttle:search; -vv is documented to expand groups, but printed the same here. php artisan route:cache compiles all routes, closures included, into bootstrap/cache/routes-v7.php (44 KB for these 24), so production skips the route files; php artisan optimize runs it with config:cache (Config and Route Caching). Two traps, reproduced: a route added after caching, then the same route also named products.index:

Output of 31
$ curl -s http://127.0.0.1:8303/new-arrivals
{"message":"No such page."}
$ php artisan route:clear
$ curl -s http://127.0.0.1:8303/new-arrivals
New arrivals
$ php artisan route:cache
   LogicException
  Unable to prepare route [new-arrivals] for serialization. Another route has already been
assigned name [products.index].

A stale cache silently ignores new routes, so never cache in development; and the duplicate name, which route() had quietly resolved to /products, failed only at cache time. When a route misbehaves, check route:list, then -v, then constraints (Route Parameters) and missing models (Route Model Binding).