Skip to content

Laravel 7.x package to add a command to find the route that will match a given URL and HTTP method

Notifications You must be signed in to change notification settings

masticore252/laravel-url-matcher-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel URL matcher command

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

About

Laravel 7.x package to add a command to find the route that will match a given URL and HTTP method

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages