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 1mo 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 1mo 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

19

—

LowBetter than 10% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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