pimvdmolen/request-cost-indicator

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

Maintainers

Package info

github.com/pimvdmolen/laravel-request-cost-indicator

pkg:composer/pimvdmolen/request-cost-indicator

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2025-12-21 20:44 UTC

This package is auto-updated.

Last update: 2026-03-21 21:10:30 UTC


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