PHPackages                             furkankufrevi/laravel-slow-query-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. furkankufrevi/laravel-slow-query-detector

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

furkankufrevi/laravel-slow-query-detector
=========================================

Detect slow queries and N+1 problems in your Laravel app. Logs warnings with query details, execution time, and origin.

00PHPCI passing

Since Mar 16Pushed 3mo agoCompare

[ Source](https://github.com/furkankufrevi/laravel-slow-query-detector)[ Packagist](https://packagist.org/packages/furkankufrevi/laravel-slow-query-detector)[ RSS](/packages/furkankufrevi-laravel-slow-query-detector/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Slow Query Detector
===========================

[](#laravel-slow-query-detector)

A lightweight Laravel package that detects slow database queries and N+1 problems, logging them with execution time and origin trace.

Installation
------------

[](#installation)

```
composer require furkankufrevi/laravel-slow-query-detector
```

The service provider is auto-discovered. To publish the config:

```
php artisan vendor:publish --tag=slow-query-detector-config
```

Setup
-----

[](#setup)

Add the middleware to your routes or groups:

```
// bootstrap/app.php (Laravel 11+)
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\SlowQueryDetector\Middleware\SlowQueryMiddleware::class);
})

// app/Http/Kernel.php (Laravel 10)
protected $middleware = [
    \SlowQueryDetector\Middleware\SlowQueryMiddleware::class,
];
```

Configuration
-------------

[](#configuration)

Set via `.env` or publish the config file:

```
SLOW_QUERY_DETECTOR_ENABLED=true
SLOW_QUERY_THRESHOLD=100
SLOW_QUERY_LOG_CHANNEL=
```

OptionDefaultDescription`enabled``true`Enable/disable the detector`threshold``100`Slow query threshold in milliseconds`detect_n_plus_one``true`Enable N+1 duplicate query detection`duplicate_threshold``3`Min repeated queries to trigger N+1 warning`log_channel``null`Log channel (null = default)`include_trace``true`Include origin stack trace in logs`trace_depth``5`Max stack frames to captureLog Output
----------

[](#log-output)

**Slow query:**

```
[Slow Query] GET /users | 250.00ms | select * from users where active = 1 | Origin: UserController.php:42

```

**N+1 detection:**

```
[N+1 Detected] GET /posts | Query repeated 15x: select * from comments where post_id = '3'

```

**Summary:**

```
[Query Summary] GET /posts | 18 queries | 320.50ms total

```

License
-------

[](#license)

MIT

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance54

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b66a7a56cce090d1bdc1e83e0f8e2e2ed1f05129e6f735ffcc69afb39cff60a3?d=identicon)[furkankufrevi](/maintainers/furkankufrevi)

---

Top Contributors

[![furkankufrevi](https://avatars.githubusercontent.com/u/46204100?v=4)](https://github.com/furkankufrevi "furkankufrevi (3 commits)")

### Embed Badge

![Health badge](/badges/furkankufrevi-laravel-slow-query-detector/health.svg)

```
[![Health](https://phpackages.com/badges/furkankufrevi-laravel-slow-query-detector/health.svg)](https://phpackages.com/packages/furkankufrevi-laravel-slow-query-detector)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B10.9k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1938.5M261](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2326.5M315](/packages/open-telemetry-sdk)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8676.7k](/packages/illuminated-console-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
