PHPackages                             yorcreative/laravel-query-watcher - 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. [Framework](/categories/framework)
4. /
5. yorcreative/laravel-query-watcher

ActiveLibrary[Framework](/categories/framework)

yorcreative/laravel-query-watcher
=================================

A Laravel package that provides configurable application query capturing &amp; monitoring.

v1.4.1(3y ago)374MITPHPPHP ^8.0CI failing

Since Aug 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/YorCreative/Laravel-Query-Watcher)[ Packagist](https://packagist.org/packages/yorcreative/laravel-query-watcher)[ RSS](/packages/yorcreative-laravel-query-watcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (6)Versions (10)Used By (0)

 [ ![Logo](content/logo.png) ](https://github.com/YorCreative)

### Laravel Query Watcher

[](#laravel-query-watcher)

[![GitHub stars](https://camo.githubusercontent.com/c343bb55acb4d50ac5365db713f4593708db7e6cffb89a6bf796e618d96a751f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f596f7243726561746976652f4c61726176656c2d51756572792d57617463686572)](https://github.com/YorCreative/Laravel-Query-Watcher/stargazers)[![GitHub issues](https://camo.githubusercontent.com/d4958838242e904c652d6c59833316d3f903540ff5ec41ac4c373ae64e0ec691/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f596f7243726561746976652f4c61726176656c2d51756572792d57617463686572)](https://github.com/YorCreative/Laravel-Query-Watcher/issues)[![GitHub forks](https://camo.githubusercontent.com/c17f4d4b1cc102273a9a5db6ff4852bfb0dd010522df776b3f2bed0ba9f7ea05/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f596f7243726561746976652f4c61726176656c2d51756572792d57617463686572)](https://github.com/YorCreative/Laravel-Query-Watcher/network)[![PHPUnit](https://github.com/YorCreative/Laravel-Query-Watcher/actions/workflows/phpunit.yml/badge.svg)](https://github.com/YorCreative/Laravel-Query-Watcher/actions/workflows/phpunit.yml)

A Laravel package that provides configurable application query capturing &amp; monitoring.

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

[](#installation)

install the package via composer:

```
composer require YorCreative/Laravel-Query-Watcher
```

Publish the packages assets.

```
php artisan vendor:publish --provider="YorCreative\QueryWatcher\QueryWatcherServiceProvider"
```

Usage
-----

[](#usage)

### Configuration

[](#configuration)

Adjust the configuration file to suite your application.

```
[
    // Do you want to capture queries?
    'enabled' => env('QUERY_WATCH_ENABLED', true),

    // Token used for Authenticating Private Broadcast Channel
    'token' => env('QUERY_WATCH_TOKEN', 'change_me'),
    'scope' => [
        'time_exceeds_ms' => [
            // Do you want to capture everything or only slow queries?
            'enabled' => env('QUERY_WATCH_SCOPE_TIME_ENABLED', true),

            // The number of milliseconds it took to execute the query.
            'threshold' => env('QUERY_WATCH_SCOPE_TIME_THRESHOLD', 500),
        ],
        'context' => [
            'auth_user' => [
                // Do you want to know context of the authenticated user when query is captured?
                'enabled' => env('QUERY_WATCH_SCOPE_CONTEXT_AUTH_ENABLED', true),

                // How long do you want the session_id/authenticated user cached for?
                // without this cache, your application will infinite loop because it will capture
                // the user query and loop.
                // See closed Issue #1 for context.
                'ttl' => env('QUERY_WATCH_SCOPE_CONTEXT_AUTH_TTL', 300),
            ],
            'trigger' => [
                // Do you want to know what triggered the query?
                // i.e Console command or Request
                'enabled' => env('QUERY_WATCH_SCOPE_TRIGGER_ENABLED', true),
            ],
        ],
        'ignorable_tables' => [
            // Do you want to capture queries on specific tables?
            // If you are utilizing the database queue driver, you need to
            // ignore the jobs table, or you'll potentially get infinite capture loops.
            'jobs',
            'failed_jobs'
        ],
        'ignorable_statements' => [
            // Do you want to ignore specific SQL statements?
            'create'
        ]
    ],
    'listener' => [
        // Channel notifications are queued
        // Define what connection to use.
        'connection' => 'sync',

        //  Define what queue to use
        'queue' => 'default',

        // Do you want to delay the notifications at all?
        'delay' => null,
    ],
    'channels' => [ // Where to send notifications?
        'discord' => [
            // Do you want discord webhook notifications?
            'enabled' => env('QUERY_WATCH_CHANNEL_DISCORD_ENABLED', false),

            // Discord Web-hook URL
            'hook' => env('DISCORD_HOOK', 'please_fill_me_in'),
        ],
        'slack' => [
            // Do you want Slack webhook notifications?
            'enabled' => env('QUERY_WATCH_CHANNEL_SLACK_ENABLED', false),

            // Slack Web-hook URL
            'hook' => env('SLACK_HOOK', 'please_fill_me_in'),
        ],
    ]
]
```

### Broadcasting

[](#broadcasting)

All captured queries will broadcast on a private channel as the primary monitoring method. The QueryEvent that is broadcasting is using your applications [broadcast configuration](https://laravel.com/docs/9.x/broadcasting#configuration).

```
    /**
     * Get the channels the event should broadcast on.
     *
     * @return PrivateChannel
     */
    public function broadcastOn(): PrivateChannel
    {
        return new PrivateChannel('query.event.'. config('querywatcher.token'));
    }

    /**
     * @return string
     */
    public function broadcastAs(): string
    {
        return 'query.event';
    }
```

### Slack Notification Channel

[](#slack-notification-channel)

To utilize Slack Notifications, you will need to [create a webhook](https://api.slack.com/messaging/webhooks#create_a_webhook) for one of your Slack Channels. Once you have your webhook url, add the following variable to your .env file.

```
SLACK_HOOK=
```

Once you have done this, you can enable Slack Notifications in the configuration file.

### Discord Notification Channel

[](#discord-notification-channel)

Get a webhook URL from discord in the channel you want to receive your notifications in by reading [Discords Introduction to Webhook Article](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks). Once you have your webhook url, add the following variable to your `.env` file.

```
DISCORD_HOOK=
```

Once you have done this, you can enable Discord Notifications in the configuration file.

### Wiki Documentation

[](#wiki-documentation)

- [Notification Channels Wiki](https://github.com/YorCreative/Laravel-Query-Watcher/wiki/Notification-Channels)
- [Screenshots](https://github.com/YorCreative/Laravel-Query-Watcher/wiki/Screenshots)

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Yorda](https://github.com/yordadev)
- [All Contributors](../../contributors)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~2 days

Total

9

Last Release

1340d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51f87d3b079a2d52ebbc2c1b71c65fe3d29717a0122436ef17f55e687ccaa1f4?d=identicon)[yordadev](/maintainers/yordadev)

---

Top Contributors

[![yordadev](https://avatars.githubusercontent.com/u/28032848?v=4)](https://github.com/yordadev "yordadev (12 commits)")

---

Tags

capture-querieshacktoberfesthacktoberfest2022laravellaravel-frameworklaravel-packagephpqueriesquery-capturequery-watcherslow-queryslow-query-monitoringsqlsql-monitoringframeworklaravelqueriesquery-watcherquery-monitoringsql monitoringcapture queriesquery captureslow query monitoring

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/yorcreative-laravel-query-watcher/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M673](/packages/laravel-socialite)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M368](/packages/laravel-zero-framework)[nutgram/nutgram

The Telegram bot library that doesn't drive you nuts

714214.9k8](/packages/nutgram-nutgram)

PHPackages © 2026

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