pimvdmolen/request-cost-indicator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

pimvdmolen/request-cost-indicator

最新稳定版本:v0.1.1

Composer 安装命令:

composer require pimvdmolen/request-cost-indicator

包简介

A lightweight, always-visible request cost awareness and analysis indicator for Laravel applications (local/staging only).

README 文档

README

Laravel PHP

A lightweight, always-visible request cost awareness and analysis indicator for Laravel applications.

Designed to make expensive requests impossible to ignore, while allowing you to drill down into why they are expensive when you choose to.

What this package does

On every HTML page load (local/staging only), it shows:

  • A small, fixed indicator at the bottom of the page with:

    • Total request time (ms)
    • Number of database queries
  • An expandable panel with:

    • A visual cost breakdown (Database / HTTP / Views / Other)
    • Minimal counters
    • A short interpretation sentence

Optionally, you can enable details mode, which captures additional data for the current request:

  • Aggregated database query timings (grouped, no SQL output)
  • External HTTP call timings
  • View render timings
  • Source locations (file + line, relative to project root)

The default mode is intentionally lightweight. Details are only collected when you explicitly ask for them.

What this package deliberately does not do (for now)

  • ❌ No per-query SQL inspection
  • ❌ No raw stack traces by default
  • ❌ No JSON / API response support
  • ❌ No frontend frameworks or build steps
  • ❌ No production usage

These boundaries are intentional and may evolve as the package grows.

Requirements

  • PHP 8.3+
  • Laravel 12+

Intended for:

  • local
  • optionally staging

Never intended for production environments.

Installation

Install the package as a dev dependency:

composer require pimvdmolen/request-cost-indicator --dev

No service provider registration is required. No assets need to be published.

Refresh a page and the indicator will appear automatically.

Enabling or disabling the indicator

By default, the indicator is enabled when:

  • APP_DEBUG=true
  • The application environment is local

You can control this via your .env file.

Enable

APP_DEBUG=true

Disable (recommended for production)

APP_DEBUG=false

You can also fine-tune this behavior in config/request-cost-indicator.php.

Details mode

By default, the indicator runs in a low-overhead mode.

To enable details for the current request:

  1. Open the panel
  2. Click Details

This triggers a page reload and enables deeper measurements for that request.

⚠️ Details mode adds overhead due to additional timing and stack inspection. Turn it off when you’re done.

Themes

The indicator supports:

  • Light mode
  • Dark mode

Your preference is stored in a cookie and persists across page loads.

Design philosophy

This package is built around a simple idea:

Make request cost visible first, explain it second.

You should notice expensive requests immediately, and only then decide how far you want to drill down.

The goal is to reduce the friction between noticing a performance problem and understanding where it comes from.

License

MIT

Author

Built by Pim van der Molen
https://pimvdmolen.nl

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固