mr-sabya / querylens
A modern API debugging and query profiling tool for Laravel.
Requires
- php: ^8.2
README
QueryLens is a modern, lightweight, and high-performance API debugging and SQL profiling tool for Laravel. It provides a real-time dashboard to monitor your application's database activity and API performance without unnecessary complexity.
โจ Features
- โก Zero-Configuration Setup
- ๐ Deep SQL Query Profiling
- ๐ Real-Time Request Monitoring
- ๐ง Query Execution Time Analysis
- ๐จ Modern Dark UI Dashboard
- ๐ฆ Dedicated SQLite Storage
- ๐ Lightweight & Fast
- ๐ฅ Slow Query Detection
- ๐ฑ Mobile Responsive Interface
- ๐ Request & Response Inspection
๐ป Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^10.0 | ^11.0 | ^12.0 |
๐ฆ Installation
Install the package via Composer:
composer require mr-sabya/querylens
Run the installation command:
php artisan querylens:install
This command will:
- Publish configuration files
- Create QueryLens storage
- Prepare SQLite logging database
- Register required assets
โ๏ธ Configuration
After installation, configure QueryLens from:
config/querylens.php
Example configuration:
<?php return [ /* |-------------------------------------------------------------------------- | Enable QueryLens |-------------------------------------------------------------------------- */ 'enabled' => env('QUERYLENS_ENABLED', true), /* |-------------------------------------------------------------------------- | Dashboard URI |-------------------------------------------------------------------------- */ 'uri' => 'querylens', /* |-------------------------------------------------------------------------- | Slow Query Threshold (milliseconds) |-------------------------------------------------------------------------- */ 'slow_query_threshold' => 500, /* |-------------------------------------------------------------------------- | Middleware |-------------------------------------------------------------------------- */ 'middleware' => [ 'web', // 'auth', ], /* |-------------------------------------------------------------------------- | Maximum Stored Logs |-------------------------------------------------------------------------- */ 'max_logs' => 5000, ];
๐ Usage
Start your Laravel application:
php artisan serve
Open the dashboard in your browser:
http://127.0.0.1:8000/querylens
QueryLens will automatically record:
- HTTP Requests
- API Calls
- SQL Queries
- Query Bindings
- Response Time
- Memory Usage
- Slow Queries
- Request Timeline
๐ Dashboard Preview
The dashboard includes:
Request Monitoring
- HTTP Method
- Route Path
- Response Status
- Request Duration
SQL Query Insights
- Raw SQL Query
- Query Bindings
- Execution Time
- Source File & Line
Performance Analysis
- Memory Consumption
- Slow Query Alerts
- Duplicate Query Detection
๐ฅ Slow Query Detection
Queries slower than the configured threshold will automatically be highlighted.
Example:
โ Slow Query Detected (842ms)
๐ Storage
QueryLens uses a dedicated SQLite database for storing logs.
This keeps your primary application database clean and optimized.
๐ Security
QueryLens is intended for local and development environments.
Disable it in production:
QUERYLENS_ENABLED=false
You may also protect the dashboard using authentication middleware:
'middleware' => [ 'web', 'auth', ],
๐งช Example Query Log
select * from users where email = ?
Execution details:
Duration: 12ms
Connection: mysql
Memory: 4MB
๐ Package Structure
src/
โโโ Commands/
โโโ Facades/
โโโ Http/
โ โโโ Controllers/
โ โโโ Middleware/
โโโ Listeners/
โโโ Models/
โโโ Providers/
โโโ Services/
โโโ Support/
โโโ resources/
โ โโโ views/
โ โโโ js/
โ โโโ css/
โโโ config/
๐ Roadmap
- Live AJAX Auto Refresh
- Real-Time WebSocket Monitoring
- Redis Monitoring
- Queue Monitoring
- Exception Tracking
- Export Logs
- Multi-Project Support
๐ค Contributing
Contributions are welcome.
- Fork the repository
- Create a new feature branch
- Commit your changes
- Push your branch
- Open a Pull Request
๐ License
This package is open-sourced software licensed under the MIT license.
โญ Support
If you find QueryLens useful, consider starring the repository on GitHub.