youngmayor/laravel-query-lens 问题修复 & 功能扩展

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

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

youngmayor/laravel-query-lens

Composer 安装命令:

composer require youngmayor/laravel-query-lens

包简介

A premium database query and performance developer dashboard for Laravel API endpoints.

README 文档

README

Latest Version on Packagist Total Downloads

Laravel Query Lens is a developer dashboard and CLI performance inspector for your Laravel database queries. It tracks query counts, duplicate SQL queries (N+1 detector), cache hit/miss ratio, memory footprint, and HTTP status codes per route. It also features a premium dark-mode Blade dashboard with a built-in SQL EXPLAIN query inspector.

Features

  • Zero-dependency dashboard: Pure Blade, Vanilla JS, and custom CSS (no Livewire or Flux required on the host application).
  • 🔍 N+1 and Duplicate Query Detection: Tracks duplicate execution counts to highlight redundant DB hits.
  • ⚙️ Performance Metrics: Measures execution duration, peak memory usage, and cache hit/miss ratio.
  • 📋 Built-in EXPLAIN Tool: Run EXPLAIN query analyzer directly from the dashboard modal.
  • 💻 CLI Console Report: Summarize endpoint performance metrics right from your terminal.
  • 🛠️ Configurable Storage: Choose between an isolated SQLite database or your host application's existing database.

Installation

Install the package via Composer:

composer require youngmayor/laravel-query-lens

Publish the package configuration:

php artisan vendor:publish --provider="Youngmayor\LaravelQueryLens\LaravelQueryLensServiceProvider" --tag="config"

This will create a config/laravel-query-lens.php configuration file in your host application.

Setup & Configuration

The package automatically registers its tracking middleware globally. You do not need to register it manually.

You can configure which routes are monitored by updating the paths array in config/laravel-query-lens.php. By default, only routes matching api/* are tracked:

'paths' => [
    'api/*', // Wildcards are supported
],

Configure Database Storage

By default, the package registers a dynamic SQLite connection named query_lens and stores logs in database/query_reporter.sqlite.

If you prefer to store metrics in your existing application database (e.g., MySQL or PostgreSQL), set the use_configured_database option to your connection name in config/laravel-query-lens.php:

'use_configured_database' => 'mysql', // Uses your default 'mysql' connection instead of SQLite

Usage

📊 Local Dashboard

The dashboard is accessible only in local and testing environments at /query-reporter (configurable via path in the config file).

🖥️ CLI Commands

Pre-load your monitored API endpoints into the database:

php artisan report:load-urls

Display endpoint stats in the terminal:

php artisan report:queries

Options:

  • --branch=: Filter records by Git branch.
  • --sort=: Sort table results by queries (default), runs, duplicates, or duration.

Testing

composer test

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固