masticore / laravel-url-matcher-command
A command to get information about the route matched against an arbitrary url string
Requires
- php: >=7.3
- illuminate/console: ^7.0|^6.0
- illuminate/http: ^7.0|^6.0
- illuminate/routing: ^7.0|^6.0
- illuminate/support: ^7.0|^6.0
Requires (Dev)
- phpunit/phpunit: ^9.2
This package is auto-updated.
Last update: 2025-04-24 12:27:50 UTC
README
Motivation
This command was created to fill the need of a way to find out which route definition will match any given url and method, this is most useful in big apps with a lot of routes where debugging this can be cumbersome.
It was inspired by symfony's bin/console router:match
command.
Install
Require this package using composer, it is recommended to install it as a development dependency.
composer require masticore/laravel-url-matcher-command --dev
Laravel's auto discovery will automatically register the command into artisan console
Usage
Given a URL and an http method, the command will search all the registered routes for a match and show all relevant information (uri, name, handler, middlweare and others)
~$ php artisan route:match api/product/3/ get +---------------------+---------------------------------------------+ | Property | Value | +---------------------+---------------------------------------------+ | Uri | api/product/{product} | | Prefix | api | | Methods | GET, HEAD | | Controller | App\Http\Controllers\ProductController@show | | Middleware | api | | Namespace | App\Http\Controllers | | Parameter Names | product | | Parameters | 123 | | Original Parameters | | | Binding Fields | | | Is Fallback | false | | Where | | +---------------------+---------------------------------------------+
TODO
- Unit tests
- Handle more use cases like route names, groups, subdomains, bindings
- support laravel versions older than 7.X
- support php versions other than 7.3 & 7.4