Download the PHP package mashiur-softzino/laravel-query-debugger without Composer
On this page you can find all versions of the php package mashiur-softzino/laravel-query-debugger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mashiur-softzino/laravel-query-debugger
More information about mashiur-softzino/laravel-query-debugger
Files in mashiur-softzino/laravel-query-debugger
Package laravel-query-debugger
Short Description Auto-detect N+1 queries, slow queries and suggest optimizations for Laravel Eloquent
License MIT
Homepage https://github.com/mash/laravel-query-debugger
Informations about the package laravel-query-debugger
Laravel Query Debugger
Auto-detect N+1 queries, duplicate queries, slow queries, and get actionable optimization suggestions for your Laravel Eloquent queries.
Stop wasting hours debugging query performance! This package automatically detects N+1 query problems, identifies slow queries, duplicate queries, SELECT * issues, and provides you with exact code suggestions to fix them.
Features
- Visual Debug Toolbar - Laravel Debugbar-like toolbar at the bottom of your page (works with Blade, Inertia, Vue, React)
- Performance Score - Get a score (0-100) with grades (A+, A, B, C, D, F) for your page's query performance
- Automatic N+1 Detection - Catches N+1 query patterns and tells you exactly where they occur
- Duplicate Query Detection - Finds exact same queries running multiple times
- *SELECT Warnings** - Identifies queries fetching all columns unnecessarily
- Slow Query Identification - Flags queries exceeding your performance thresholds
- Actionable Suggestions - Get before/after code examples to fix issues
- Context Tracking - Know exactly which file and line triggered each query
- Beautiful Reports - Export detailed HTML or JSON reports
- Zero Config - Works out of the box with sensible defaults
- Production Safe - Automatically disabled in production
- Framework Agnostic - Works with Blade, Inertia.js, Vue.js, React, and any SPA
Screenshots
Visual Debug Toolbar (Collapsed)
Visual Debug Toolbar (Expanded)
Installation
You can install the package via composer:
The package will automatically register itself via Laravel's auto-discovery.
Configuration
Publish the configuration file (optional):
This will create a config/query-debugger.php file where you can customize:
Environment Variables
Add these to your .env file:
Usage
Visual Debug Toolbar (Recommended)
The package automatically injects a debug toolbar at the bottom of your HTML pages. No configuration needed!
Features:
- Collapsible/expandable panel
- Drag to resize
- Performance score with grade (A+, A, B, C, D, F)
- N+1 issue details with fix suggestions
- Duplicate query detection
- SELECT * warnings
- Works with all frontend frameworks (Blade, Inertia, Vue, React)
Middleware Setup
Add the middleware to see the toolbar. In app/Http/Kernel.php:
Or for Laravel 11+ in bootstrap/app.php:
Command Line Usage
You'll get a beautiful console output showing:
Command Options
Using the Facade
You can also interact with the query logger programmatically:
Performance Scoring
The package calculates a performance score (0-100) based on:
| Factor | Impact |
|---|---|
| Total queries > 10 | -5 points |
| Total queries > 20 | -10 points |
| Total time > 100ms | -5 points |
| Total time > 500ms | -15 points |
| Each N+1 issue | -15 points (max -30) |
| Each duplicate query | -5 points (max -15) |
| Each SELECT * query | -2 points (max -10) |
| Slow queries | -5 points each (max -15) |
Grade Scale
| Score | Grade | Label |
|---|---|---|
| 95-100 | A+ | Excellent |
| 85-94 | A | Good |
| 70-84 | B | Needs Improvement |
| 50-69 | C | Poor |
| 25-49 | D | Very Poor |
| 0-24 | F | Critical |
Real-World Examples
N+1 Problem Detection
Your Code:
Package Output:
Fixed Code:
Duplicate Query Detection
Your Code:
Package Output:
SELECT * Warning
Your Code:
Package Output:
Configuration Reference
Thresholds
Detection Settings
Middleware Settings
Context Tracking
Note: Uses
debug_backtrace()which has performance overhead. Automatically disabled in production.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Mashiur Rahman
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Support
If you find this package helpful, please consider giving it a ⭐ on GitHub!
For issues or questions, please open an issue on GitHub.
All versions of laravel-query-debugger with dependencies
illuminate/contracts Version ^10.0||^11.0||^12.0
spatie/laravel-package-tools Version ^1.16