November 26th, 2021

View your Laravel routes in your browser

View your Laravel routes in your browser

Patompong Savaengsuk created a package that adds a route to your Laravel application. The route will render all your Laravel routes in a nice HTML format. It also has a minimal filter input that you can use to filter by route URI or route Name.

You can install the package via composer:

1composer require s-patompong/laravel-routes-html

You can publish the config file with:

1php artisan vendor:publish --tag="routes-html-config"

Publish the views using:

1php artisan vendor:publish --tag="routes-html-views"

In the config file, you can configure when to make the /route-list endpoint available. By default they views are only available when APP_DEBUG is true.

1return [
2 /**
3 * Either you want to enable or disable the route
4 * It should be enabled only in the local environment
5 * By default, it'll be enabled if the app.debug is true
6 */
7 'enabled' => (bool) env('ROUTES_HTML_ENABLED', config('app.debug')),
8 
9 /**
10 * The route URI
11 */
12 'uri' => '/route-list',
13 
14 /**
15 * The route name
16 */
17 'route_name' => 'routes',
18 
19 /**
20 * The list of route to ignore
21 */
22 'ignore_routes' => [
23 'routes-html/*',
24 '_ignition/*',
25 'sanctum/*',
26 'livewire/*',
27 ],
28];

This can come in handy when dealing with long and messy routes generated by the route:list command.

Github repo

Statamic Ninja

Comments

Marian Pop

PHP / Laravel Developer. Writing and maintaining @LaravelMagazine. Host of "The Laravel Magazine Podcast". Pronouns: vi/vim.

Subscribe to our newsletter

Get latest news, tutorials, community articles and podcast episodes delivered to your inbox.

Weekly articles
We send a new issue of the newsletter every week on Friday.
No spam
We'll never share your email address and you can opt out at any time.