Search by

Request, SQL and rendering profiler for Lemonade Framework with an interactive debug toolbar and request history.

Package info

github.com/johnnyxlemonade/profiler

pkg:composer/johnnyxlemonade/profiler

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-11-27 14:46 UTC

This package is auto-updated.

Last update: 2026-11-27 14:46:45 UTC


README

Tests PHP 8.3–8.6 PHPStan License

Introduction

Lemonade Profiler adds request, SQL, and rendering diagnostics to Lemonade Framework applications. It provides an interactive toolbar, recent request history, and a detail page for each saved profile.

Features

  • Shadow DOM debug toolbar on eligible HTML responses, with light and dark appearance.
  • HTTP timing, status, route, and peak PHP memory measurements.
  • SQL totals, raw queries, bind values, normalized fingerprints and relevant query sources.
  • Request timeline and view rendering measurements, with durations shown in milliseconds or microseconds.
  • Duration and SQL comparisons with earlier requests to the same route and method when enough history is available.
  • Searchable request history with status, method, and time filters.
  • Session, Server/PHP, and Composer diagnostics.
  • Czech and English interface, including a language switch.
  • Fetch and XHR request monitoring in the toolbar for profiled same-origin responses.

Screenshots

Debug Toolbar

Lemonade Profiler debug toolbar

Inspect current request metrics and SQL details without leaving the page.

Request Details

Lemonade Profiler request details

Review timing, complete SQL diagnostics, rendering, and comparison data for one request.

Request Details — Dark

Lemonade Profiler request details in dark mode

Use the same complete diagnostic view in dark mode.

Request History

Lemonade Profiler request history

Find recent requests with search and filters.

Requirements

  • PHP 8.3 or newer (>=8.3), tested on PHP 8.3, 8.4, 8.5 and 8.6.
  • johnnyxlemonade/framework:dev-main.

Installation

Install the current public development version with Composer:

composer require johnnyxlemonade/profiler:dev-main

Add the provider after your existing providers in app/Config/Providers.yaml:

module: providers
config:
  providers:
    - Lemonade\Profiler\ProfilerServiceProvider

The regular require dependency remains available after a production composer install --no-dev. If you instead install with composer require --dev, that deployment omits the package; remove its provider registration there as well.

Usage

The toolbar appears on eligible HTML responses when the provider is registered and the profiler is enabled. Its HTTP panel also lists profiled same-origin Fetch and XHR responses made after the toolbar loads. Use the toolbar links or open /_lemonade/profiler for request history and /_lemonade/profiler/request/{id} for a saved request's details.

History supports server-side search by route, path template, or controller, plus status, method, and time filters. Results use stable anchored cursor navigation and only the current group of up to 25 summaries is rendered. Request details show measurements and, when at least five comparable earlier requests exist, duration and SQL comparisons. The toolbar and profiler pages support Czech and English; use their CS/EN switch or ?lang=cs / ?lang=en on profiler pages.

SQL details

The database panel keeps the framework's query count and execution time, and shows each captured query in an expandable detail. It retains the exact SQL text passed to the database layer together with bind values in execution order and their PHP scalar types. For display, available bindings are substituted into placeholders so the toolbar and detail page show one complete diagnostic SQL statement. The detail also shows the first caller above the profiler/database plumbing.

Query fingerprints are normalized separately from the displayed SQL, so queries with the same shape remain grouped even when their inline literals or bind values differ. Three or more repeated SELECT statements are labeled suspected N+1; this is a heuristic, not proof of an N+1 issue. The panel does not execute additional SQL. SQL detail and source tracing add CPU and memory cost only while profiling is enabled and are bounded by the configured detail limits. Existing SQL totals remain measurements from the framework, including queries beyond the detail limit.

Configuration

Registering the provider enables profiling by default. ProfilerConfig::enabled() controls activation independently of APP_ENV and APP_DEBUG. To disable it, bind a ProfilerConfig with enabled: false in the root container before kernel bootstrap; see activation and access control.

By default, storage retains up to 100 profiles for one hour. Capture is limited to 200 SQL details and 200 rendering calls per request, with a 1 MiB saved profile limit and a 2 MiB HTML inspection limit. These limits can be changed through ProfilerConfig.

Bind the configuration in the root container before kernel bootstrap. Named arguments let the application override only the limits it needs:

use Lemonade\Profiler\ProfilerConfig;

$container->singleton(ProfilerConfig::class, new ProfilerConfig(
    maxProfiles: 250,
    retentionSeconds: 7200,
    maxQueries: 300,
    slowQueryMs: 50.0,
));

maxSqlLength limits retained raw SQL and normalized fingerprint text to 4,096 bytes by default. slowQueryMs marks queries taking at least 100 milliseconds as slow by default. See activation and access control for disabling the profiler and protecting its endpoints.

Private storage keeps lightweight request summaries as bounded LDJSON in history.ldjson. Complete request details are appended to at most ten 10 MiB LDJSON segments under profiles/ and loaded only for an opened detail. Stable Server/PHP and Composer metadata are content-addressed under environments/, so profiles captured in the same environment reference one shared snapshot instead of duplicating it. Storage publication, segment rotation, history pruning and whole-file deletion share one local lock.

Security

Profiler can run in any environment. For a public production deployment, protect /_lemonade/profiler and all its subpaths from unauthorized access before requests reach the application. The package does not provide authentication for these endpoints; see activation and access control.

Profiles and toolbar payloads contain raw SQL, inline SQL literals and bind values. Treat profiler output, storage and endpoints as sensitive debugging data and never expose them without access control. Request bodies, query strings, cookies and session values are still not retained. Shadow DOM isolates toolbar styles, but does not isolate its JavaScript security context. A restrictive Content Security Policy can block the interactive toolbar.

Development

From the package root:

composer install
composer test
composer stan
composer cs:check
composer qa

License

Lemonade Profiler is licensed under the Apache License 2.0. Included Bootstrap Icons artwork is licensed under the MIT License; see third-party notices.