logo
podcast Podcast
get help Get Unstuck

Seeing the route list in definition order

So much to say about routes

Joel Clermont
Joel Clermont
2024-12-19

Yesterday, I talked about how fallback routes work and I had one more route-related tidbit to share, that just didn't fit in that tip.

There is a useful new feature just added in Laravel 11.35.0 that lets you display the route list by order.

Why is this useful?

Normally, when you run php artisan route:list, the results are sorted by URL. This makes logical sense, and most times it is the order you want.

The problem is that it obscures the order your routes were defined in, making it hard to understand how duplicate routes would be resolved without opening the routes file.

Now, there's a new --sort=definition option you can pass that will preserve the order routes were defined in, giving you an easier way to see how routes are resolved right from the command line.

Here to help,

Joel

P.S. Don't code alone. There is a lot of benefit to having a small group of trusted developers to lean on when you need it. It can really level up your skills.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.