Download the PHP package evgeny-korovin/laravel-query-logger without Composer
On this page you can find all versions of the php package evgeny-korovin/laravel-query-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download evgeny-korovin/laravel-query-logger
More information about evgeny-korovin/laravel-query-logger
Files in evgeny-korovin/laravel-query-logger
Package laravel-query-logger
Short Description SQL query logging and inspection tools for Laravel.
License MIT
Informations about the package laravel-query-logger
Laravel Query Logger
evgeny-korovin/laravel-query-logger is a Laravel package that automatically records executed SQL queries and helps you find slow parts of your application.
Русская версия
Features
- automatic SQL query logging through
DB::listen; - storage of the actual SQL with bindings substituted;
- storage of execution time, database connection, and query timestamp;
- storage of the HTTP context: route name, URL, and IP address;
- detection of the application class and method that issued the query;
- a web interface with query listing, search, sorting, and pagination;
- color-coded queries based on execution time;
EXPLAINsupport for queries andEXPLAIN ANALYZEforSELECTstatements;- caching of the EXPLAIN result in the query record;
- deletion of all stored logs from the interface;
- optional AI query optimization recommendations through OpenCode;
- safe logger behavior: a logging failure does not interrupt the original query.
Requirements
- PHP 8.2 or newer;
- Laravel 12 or 13;
- a Laravel-supported database with a
query_logstable.
Installation
Install the package through Composer:
Laravel will automatically discover the package service provider. Migrations are loaded automatically and will run with the regular migration command:
The query list includes Tailwind CSS through its official CDN script, so it works without adding npm packages or changing the application's frontend build.
After installation, open:
For example, if your application is running at http://localhost, the interface will be available at http://localhost/sql-queries.
Configuration
Publish the configuration file if needed:
The configuration file will be located at config/query-logger.php.
Query execution time thresholds can be configured using environment variables:
Queries up to the warning threshold use the regular row color, queries between the warning and critical thresholds are highlighted in yellow, and queries above the critical threshold are highlighted in red.
AI Recommendations
The AI advice button sends the SQL and EXPLAIN result to the selected AI provider. The package supports providers with an OpenAI-compatible API. You can configure the URL, API key, model, and additional headers for each provider.
OpenCode is used by default:
To use OpenAI, set:
The model can be overridden for a specific provider with OPENCODE_MODEL or OPENAI_MODEL. The list of providers, their URLs, and additional headers are configured in config/query-logger.php:
If QUERY_LOGGER_AI_MODEL is not set, the selected provider's model is used. If the selected provider's API key is not configured, the package's other features continue to work, but AI recommendations will be unavailable.
Routes
The package registers routes with the web middleware:
| Method | URI | Purpose |
|---|---|---|
GET |
/sql-queries |
list and search queries |
DELETE |
/sql-queries |
delete all records |
GET |
/sql-queries/{queryLog}/explain |
get EXPLAIN |
POST |
/sql-queries/{queryLog}/ai-advice |
get AI recommendations |
Routes are not restricted by authorization by default. In production, make sure to protect the interface and delete operations with your own middleware or restrict access at the web server level.
What Is Not Logged
The package ignores queries against the query_logs table to prevent recursion, as well as EXPLAIN queries executed by the interface itself.
License
This package is distributed under the MIT license.
Русская версия
All versions of laravel-query-logger with dependencies
illuminate/database Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/view Version ^12.0|^13.0