27

GitHub - julienbourdeau/route-usage: Log what routes were used and when. Easily...

 4 years ago
source link: https://github.com/julienbourdeau/route-usage
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

Route Usage for Laravel

Latest Version on Packagist Build Status

This package keeps track of all requests to know what controller method, and when it was called. The goal is not to build some sort of analytics but to find out if there are unused endpoints or controller method.

After a few years, any projects have dead code and unused endpoint. Typically, you removed a link on your frontend, nothing ever links to that old /special-page. You want to remove it, but you're not sure. Have look at the route_usage table and figure out when this page was accessed for the last time. Last week? Better keep it for now. 3 years ago? REMOVE THE CODE! 🥳

Screenshot 2019-10-20 at 19 14 39

Screenshot 2019-10-20 at 19 15 19

Installation

You can install the package via composer:

composer require julienbourdeau/route-usage

Usage

Head over to yourapp.tld/route-usage. Please note that this page is publicly accessible.

Notes

  • The page showing route usage is currently publicly available. (see TODO)
  • I only logs request with a 2xx or 3xx HTTP response. I don't think the rest makes sense. Your opinion is welcome!
  • In the very first version, I was incrementing a count attribute. I removed it because I think it gives a wrong information. If it was used a lot because but last access was a year ago, it gives a false sense of importance to this unused route.
  • The HTML page with the table is volontarily not using any CSS: I want it to be very low footprint and as easy as possible to maintain.

Todo

  • Disable HTML page by default ?
  • Add option to put page behind middleware (like dev in Laravel Spark)
  • Add support for Redis to log updated_at

About

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

License

The MIT License (MIT). Please see License File for more information.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK