Skip to content

Conversation

@mathieutu
Copy link
Contributor

@mathieutu mathieutu commented Nov 29, 2024

Hello,

By default, routes are sorted by uri.
However, it's not easy to see which routes will take precedence on the others (especially when routes are coming from a package).

This PR adds a --sort=precedence option to display the routes by their original order.

It also removes useless code, and adds a test to be sure we don't have any regression.

PS: in the edge case where an array is passed like ['domain', 'precedence'], it still will work as planned, as null will be compared to null in the sort callback.

Thanks.
Mathieu.

@mathieutu
Copy link
Contributor Author

Tests are failing for a unrelated reason.

Symfony\Component\Mailer\Exception\UnsupportedSchemeException: The "" scheme is not supported; supported schemes for mailer "smtp" are: "smtp", "smtps".

@mathieutu mathieutu changed the title [11.x] Allow sorting route by precedence. [11.x] Allow sorting routes by precedence in artisan routes:list. Nov 29, 2024
Comment on lines 119 to 123
if (($sort = $this->option('sort')) !== null) {
$routes = $this->sortRoutes($sort, $routes);
} else {
$routes = $this->sortRoutes('uri', $routes);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option is by 'uri' by default, so it seems not needed, as it's never null. I added a test to be sure of it.

@taylorotwell taylorotwell merged commit 9a9cb2f into laravel:11.x Nov 29, 2024
38 checks passed
@taylorotwell
Copy link
Member

Renamed option to definition.

@taylorotwell
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants