定制 julienbourdeau/route-usage 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

julienbourdeau/route-usage

Composer 安装命令:

composer require julienbourdeau/route-usage

包简介

Log what routes were used and when. Easily figure out if one hasn't been called in a long time (and delete it! 🥳)

README 文档

README

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! 🥳

/route-usage screenshot

php artisan usage:route screenshot

Installation

You can install the package via composer:

composer require julienbourdeau/route-usage

Run migrations to create the new route_usage table.

php artisan migrate

Publish configuration

php artisan vendor:publish --provider="Julienbourdeau\RouteUsage\RouteUsageServiceProvider"

Usage

To access the route usage, you can do it in your terminal with the command.

php artisan usage:route

To access the HTML table, you'll first need to define who can access it. By default, it's available only on local environment.

In your AuthServiceProvide, in the boot method, define who can access this page:

Gate::define('viewRouteUsage', function ($user) {
    return $user->isSuperAdmin();
});

Then, head over to yourapp.tld/route-usage.

Configuration

excluding-regex

Here you may specify regex to exclude routes from being logged. Typically, you want may want to exclude routes from packages or dev controllers. The value must be a valid regex or anything falsy.

Notes

  • 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.

Road to 1.0 release

Less SQL queries

I'll like to reduce the number of SQL queries performed. Typically, if a route is called, we don't need to log usage for the next 5 minutes. I'm thinking we could use some cache or split the data: attributes in mysql but last used date in Redis.

💡 Feel free to open an issue to discuss your ideas.

More package to ignore

Today, we ignore routes from Nova or Debugbar because there is nothing you can do about these routes. I'd like to support more packages out of the box.

📦 What package would you like to see added?

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 julien@sigerr.org 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.

julienbourdeau/route-usage 适用场景与选型建议

julienbourdeau/route-usage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64.46k 次下载、GitHub Stars 达 276, 最近一次更新时间为 2019 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「julienbourdeau」 「route-usage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 julienbourdeau/route-usage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 julienbourdeau/route-usage 我们能提供哪些服务?
定制开发 / 二次开发

基于 julienbourdeau/route-usage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

与 julienbourdeau/route-usage 相关的其它包

同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:

统计信息

  • 总下载量: 64.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 277
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 276
  • Watchers: 3
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-20