Search code examples
phplaravelrouteslaravel-artisan

Laravel 5.6 artisan command to get route from URI


I'm relatively new to laravel, but was wondering if there is a way using artisan to have it return the route that would be run if supplied a given request URI.

I know I can get a list or routes using:

php artisan route:list

And I can filter routes with --name, --method, --path, etc., but I'm looking for a method to supply a URI path, and have artisan return the route that would match...

Something like

php artisan route:list --requestURI=blog/this-is-my-slug/

with the desired result showing the route URI that laravel would have been directed it to... such as blog/{slug}

Is there anyway to get the route from a request URI using artisan?


Solution

  • Currently there is no predefined command exists for this. But you can do it by creating your own artisan commands. Check official Laravel documentation for custom commands in here.