PHPackages                             saasscaleup/laravel-n-plus-one-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. [Database &amp; ORM](/categories/database)
4. /
5. saasscaleup/laravel-n-plus-one-detector

ActiveLibrary[Database &amp; ORM](/categories/database)

saasscaleup/laravel-n-plus-one-detector
=======================================

Real-time detection and resolution of N+1 query issues for Laravel applications. Support now Laravel 11

v1.0.6(1y ago)49782↑66.7%4[1 issues](https://github.com/saasscaleup/laravel-n-plus-one-detector/issues)MITPHPPHP ^7.3|^8.0

Since Jul 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/saasscaleup/laravel-n-plus-one-detector)[ Packagist](https://packagist.org/packages/saasscaleup/laravel-n-plus-one-detector)[ Docs](https://github.com/saasscaleup/laravel-n-plus-one-detector)[ Fund](https://buymeacoffee.com/scaleupsaas)[ GitHub Sponsors](https://github.com/saasscaleup)[ RSS](/packages/saasscaleup-laravel-n-plus-one-detector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

[![Laravel N+1 Query Detector](https://github.com/saasscaleup/laravel-n-plus-one-detector/raw/master/nplusone-saasscaleup.png?raw=true)](https://github.com/saasscaleup/laravel-n-plus-one-detector/blob/master/nplusone-saasscaleup.png?raw=true)

Real-time detection and resolution of N+1 query issues for Laravel applications. Provides detailed insights, advanced notifications, and a rich admin dashboard.
=================================================================================================================================================================

[](#real-time-detection-and-resolution-of-n1-query-issues-for-laravel-applications-provides-detailed-insights-advanced-notifications-and-a-rich-admin-dashboard-)

#### Perfect for solo developers and teams. Compatible with Laravel 5.5+ and PHP 7+.

[](#perfect-for-solo-developers-and-teams-compatible-with-laravel-55-and-php-7)

####  [Youtube](https://youtube.com/@ScaleUpSaaS)  ·  [Twitter](https://twitter.com/ScaleUpSaaS)  ·  [Facebook](https://facebook.com/ScaleUpSaaS)  ·  [Buy Me a Coffee](https://buymeacoffee.com/scaleupsaas)

[](#--youtube------twitter------facebook------buy-me-a-coffee)

 [ ![Latest Stable Version](https://camo.githubusercontent.com/63f0defc868b140e4f4966385bb383cfacaaa847017527f7f9b9dd7b350532f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736161737363616c6575702f6c61726176656c2d6e2d706c75732d6f6e652d6465746563746f722e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/saasscaleup/laravel-n-plus-one-detector) [ ![Total Downloads](https://camo.githubusercontent.com/70d4f94a11864eb58fe166a1aae4b3a4b249dbb1954cac234d2550f09160c76f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736161737363616c6575702f6c61726176656c2d6e2d706c75732d6f6e652d6465746563746f722e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/saasscaleup/laravel-n-plus-one-detector) [ ![License](https://camo.githubusercontent.com/b8c19cdf4f7bd8638d9862a4459890cdd73dcce5ead11755d2aab6ad831ca322/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736161737363616c6575702f6c61726176656c2d6e2d706c75732d6f6e652d6465746563746f722e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/saasscaleup/laravel-n-plus-one-detector)

[![banner](https://github.com/saasscaleup/laravel-n-plus-one-detector/raw/master/dashboard.png?raw=true)](https://github.com/saasscaleup/laravel-n-plus-one-detector/blob/master/dashboard.png?raw=true)

---

Laravel N+1 Query Detector
==========================

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

Laravel N+1 Query Detector is a powerful package designed to help you identify and resolve N+1 query problems in real-time. Perfect for individual developers and teams, this package enhances your application’s performance by catching inefficient queries before they impact your users.

✨ Features
----------

[](#-features)

- **Real-time N+1 Query Detection**: Identify N+1 queries as they happen, ensuring your application remains performant.
- **Detailed Query Insights**: Get detailed information about each detected N+1 query, including file line, the class and methods involved.
- **Advanced Notifications**: Receive alerts via Slack, webhooks, or email, ensuring you never miss an important notification.
- **Rich Admin Dashboards**: View all N+1 warnings in a comprehensive and user-friendly dashboard.
- **Suit for Teams and Solo Developers**: Designed to be used by both solo developers and teams working collaboratively.

Requirements
------------

[](#requirements)

- PHP &gt;= 7
- Laravel &gt;= 5.5

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

[](#installation)

### Install composer package (dev)

[](#install-composer-package-dev)

Via Composer - Not recommended for production environment

```
composer require --dev saasscaleup/laravel-n-plus-one-detector
```

---

### Publish package's config, migration and view files

[](#publish-packages-config-migration-and-view-files)

Publish package's config, migration and view files by running below command:

Try this command first

```
php artisan vendor:publish --provider="Saasscaleup\NPlusOneDetector\NPlusOneDetectorServiceProvider"
```

If you are getting this result:

```
No publishable resources for tag [].
Publishing complete.

```

Than try to this:

```
php artisan vendor:publish
```

and then enter the number of that represent the provider (in the example below the number is **14**)

```
  [13] Provider: Saasscaleup\LogAlarm\LogAlarmServiceProvider
  [14] Provider: Saasscaleup\NPlusOneDetector\NPlusOneDetectorServiceProvider

> 14

```

### Run migration command

[](#run-migration-command)

Run `php artisan migrate` to create `nplusone_warnings` table.

```
php artisan migrate
```

### Run route:cache command

[](#run-routecache-command)

Run `php artisan migrate` to make sure route cache will be purge becasue we are adding new route `/n-plus-one-dashboard`.

```
php artisan route:cache
```

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

[](#configuration)

You can configure the package by editing the `config/n-plus-one.php` file. This file allows you to set the threshold for detecting N+1 queries, notification preferences, and more.

```
