PHPackages                             jeysonlesmes/laravel-query-detector-with-ajax-requests - 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. jeysonlesmes/laravel-query-detector-with-ajax-requests

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

jeysonlesmes/laravel-query-detector-with-ajax-requests
======================================================

Laravel N+1 Query Detector

010PHP

Since Aug 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jeysonlesmes/laravel-query-detector-with-ajax-requests)[ Packagist](https://packagist.org/packages/jeysonlesmes/laravel-query-detector-with-ajax-requests)[ RSS](/packages/jeysonlesmes-laravel-query-detector-with-ajax-requests/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/62ba486abb09262b622a314220e4bb0172ee8287588ad0db7d0d5b0f3af3ef3b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d71756572792d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-query-detector)[![Build Status](https://camo.githubusercontent.com/05773a375844ded13fc04ea9d382d444271e183a7edab1c32486842b5765bb03/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6265796f6e64636f64652f6c61726176656c2d71756572792d6465746563746f722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/beyondcode/laravel-query-detector)[![Quality Score](https://camo.githubusercontent.com/67abaf409431fe4d14c2d2e7344149955e62f6280e9ce017b6841a298bcb50f7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6265796f6e64636f64652f6c61726176656c2d71756572792d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/beyondcode/laravel-query-detector)[![Total Downloads](https://camo.githubusercontent.com/107158b9e6c83754b1cbc42f6cad02c7a1a1a4bf19cacf54deab7a24505084b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d71756572792d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-query-detector)

The Laravel N+1 query detector helps you to increase your application's performance by reducing the number of queries it executes. This package monitors your queries in real-time, while you develop your application and notify you when you should add eager loading (N+1 queries).

[![Example alert](https://camo.githubusercontent.com/b8ab2382c04c43c7a8b5e25e496ce754298cf99536745ad82f6b9d58e04eccaa/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6e2b312f616c6572742e706e67)](https://camo.githubusercontent.com/b8ab2382c04c43c7a8b5e25e496ce754298cf99536745ad82f6b9d58e04eccaa/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6e2b312f616c6572742e706e67)

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

[](#installation)

You can install the package via composer:

```
composer require beyondcode/laravel-query-detector --dev
```

The package will automatically register itself.

Usage
-----

[](#usage)

If you run your application in the `debug` mode, the query monitor will be automatically active. So there is nothing you have to do.

By default, this package will display an `alert()` message to notify you about an N+1 query found in the current request.

If you rather want this information to be written to your `laravel.log` file, written to your browser's console log as a warning or listed in a new tab for the [Laravel Debugbar (barryvdh/laravel-debugbar)](https://github.com/barryvdh/laravel-debugbar), you can publish the configuration and change the output behaviour (see example below).

You can publish the package's configuration using this command:

```
php artisan vendor:publish --provider=BeyondCode\\QueryDetector\\QueryDetectorServiceProvider
```

This will add the `querydetector.php` file in your config directory with the following contents:

```
