laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

getRoutesByPath: Filter the routes by path #2589

Closed sinkcup closed 3 years ago

sinkcup commented 3 years ago
$ php artisan route:list --help

Options:
      --method[=METHOD]    Filter the routes by method
      --name[=NAME]        Filter the routes by name
      --path[=PATH]        Filter the routes by path

route command has 3 filters, but only 2 in code:

image

Route::getRoutes()->getRoutesByMethod();
Route::getRoutes()->getRoutesByName();

https://github.com/laravel/framework/blob/277c2fbd0cebd2cb194807654d870f4040e288c0/src/Illuminate/Routing/CompiledRouteCollection.php#L270

suggestion: support getRoutesByPath: Filter the routes by path

Route::getRoutes()->getRoutesByPath();
themsaid commented 3 years ago

Feel free to open a PR.