PHPackages                             sofa/laravel-db-queries-alert - 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. sofa/laravel-db-queries-alert

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

sofa/laravel-db-queries-alert
=============================

Insanely simple check against DB querying abuse in Laravel app AKA Check Your Queries Bro!

v0.1.1(7y ago)72.5k1MITPHPPHP &gt;=7.1.0

Since Jun 30Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jarektkaczyk/laravel-db-queries-alert)[ Packagist](https://packagist.org/packages/sofa/laravel-db-queries-alert)[ RSS](/packages/sofa-laravel-db-queries-alert/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Sofa/DbQueriesAlert
===================

[](#sofadbqueriesalert)

#### aka Check Your Queries Bro!

[](#aka-check-your-queries-bro)

[![Downloads](https://camo.githubusercontent.com/85e7edc923c200bb688c83721fc2071cc17ba071e4d437fd4d3aa1c654bbaf47/68747470733a2f2f706f7365722e707567782e6f72672f736f66612f6c61726176656c2d64622d717565726965732d616c6572742f646f776e6c6f616473)](https://packagist.org/packages/sofa/laravel-db-queries-alert) [![stable](https://camo.githubusercontent.com/eb92568088d78445297d6e4da4e71b4640d687bb97315a5ef5e4bbb7f497e0c8/68747470733a2f2f706f7365722e707567782e6f72672f736f66612f6c61726176656c2d64622d717565726965732d616c6572742f762f737461626c652e737667)](https://packagist.org/packages/sofa/laravel-db-queries-alert)

Laravel &amp; Eloquent are beautiful and easy to use. Many packages make things even easier, which is brilliant! There's price to that though. Often you may find yourself in a situation when your app slows down or freezes completely without any significant change in the code. One of the reasons to that might be **database querying abuse** by hitting `N+1` query problem on Eloquent relations, or some magic setup in a package you're using somewhere.

---

This package will help you with this problem by checking queries being run and logging `info|warning|error` when specified thresholds are exceeded.

**Aim of the package is simply alerting you, without getting into details**. It provides you some hints on where to look at, and either you spot the problem yourself right away, or you would resort to more in-depth analysis with [laravel-debugbar](https://github.com/barryvdh/laravel-debugbar), [blackfire](https://blackfire.io), [xdebug](https://xdebug.org) or any other tool of your choice.

Usage
-----

[](#usage)

After you [installed](#installation) the package you can customize the thresholds publish configuration by calling:

```
$ php artisan vendor:publish --provider="Sofa\DbQueriesAlert\ServiceProvider"

```

and edit it in `config/db_queries_alert.php`:

```
return [
    'error' => 100,
    'warning' => 50,
    'info' => 20,
];
```

Now you're good to go. The package will call `Log::error` (or `warning|info`) whenever your app hits given threshold. Catch this error in the monitoring service you're using for the application (or simply check your local `storage/logs/laravel[-YYYY-MM-DD].log` file).

#### Note

[](#note)

This package depends fully on Laravel and is supposed to be used only there, thus there's no DI, it shamelessly uses facades and helpers and does not even try to hide it ¯\\*(ツ)*/¯

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

[](#installation)

1. Add package to your project:

    ```
    path/to/your/app$ composer require sofa/laravel-db-queries-alert

    ```
2. Then add provider manually to your `config/app.php`:

    *Package supports **auto-discovery** so this step is required only for Laravel 5.4.*

    ```
    // config/app.php

        'providers' => [
            ...
            Sofa\DbQueriesAlert\ServiceProvider::class,
        ],
    ```
3. Add entry to the global middleware stack in `app/Http/Kernel.php` file and flag to your `.env` file:

    ```
    // app/Http/Kernel.php
    class Kernel extends HttpKernel
    {
        /**
         * The application's global HTTP middleware stack.
         *
         * These are run for every single Request.
         *
         * @var array
         */
        protected $middleware = [
            ...
            \Sofa\DbQueriesAlert\Middleware::class,
        ];

    // .env
    DB_QUERIES_ALERT_ENABLED=true
    ```

#### Contribution

[](#contribution)

All contributions are welcome, PRs must be **PSR-2 compliant**.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

2870d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/34d383bf50d6c73fc747d89a5efacd41ccecc9695aec04148a7c04fc00ef26e7?d=identicon)[jarektkaczyk](/maintainers/jarektkaczyk)

---

Top Contributors

[![jarektkaczyk](https://avatars.githubusercontent.com/u/6928818?v=4)](https://github.com/jarektkaczyk "jarektkaczyk (3 commits)")[![amaelftah](https://avatars.githubusercontent.com/u/17250137?v=4)](https://github.com/amaelftah "amaelftah (1 commits)")

---

Tags

laravelloggingdatabaseeloquentqueries

### Embed Badge

![Health badge](/badges/sofa-laravel-db-queries-alert/health.svg)

```
[![Health](https://phpackages.com/badges/sofa-laravel-db-queries-alert/health.svg)](https://phpackages.com/packages/sofa-laravel-db-queries-alert)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[mvanduijker/laravel-transactional-model-events

Add eloquent model events fired after a transaction is committed or rolled back

75164.5k](/packages/mvanduijker-laravel-transactional-model-events)[guidocella/eloquent-populator

Guess attributes for Eloquent model factories

7661.6k2](/packages/guidocella-eloquent-populator)

PHPackages © 2026

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