PHPackages                             huubverbeek/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. huubverbeek/query-watcher

ActiveLibrary[Framework](/categories/framework)

huubverbeek/query-watcher
=========================

A package to watch queries in your Laravel application -- including PHPUnit asserts.

v1.0.5(2y ago)16.0k↑33.3%MITPHP

Since May 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/HuubVerbeek/query-watcher)[ Packagist](https://packagist.org/packages/huubverbeek/query-watcher)[ RSS](/packages/huubverbeek-query-watcher/feed)WikiDiscussions main Synced yesterday

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

### QueryWatcher

[](#querywatcher)

QueryWatcher is a composer package for Laravel that allows you to monitor and analyze database queries executed during the runtime of your application. It provides methods to track slow queries and identify duplicate queries.

#### Installation

[](#installation)

You can install the QueryWatcher package via Composer by running the following command:

`composer require huubverbeek/query-watcher`

#### Requirements

[](#requirements)

This package requires php 8.1 or higher.

#### Usage

[](#usage)

To start watching queries, you can use the `watch` method provided by the `QueryWatcher` facade:

```
use HuubVerbeek\QueryWatcher\Facades\QueryWatcher;

QueryWatcher::watch();
```

This will enable the query watcher and start collecting executed queries.

#### All Queries

[](#all-queries)

To retrieve all the queries you can use the `queries` method:

```
$allQueries = QueryWatcher::queries();
```

#### Slow Queries

[](#slow-queries)

To retrieve the slow queries (queries that exceed a certain execution time), you can use the `slowQueries` method:

```
$slowQueries = QueryWatcher::slowQueries();
```

You can also set a custom threshold (the default is one second) for slow queries by using the `setSlowThreshold` method:

```
QueryWatcher::setSlowThreshold(2.0); // Set slow threshold to 2 seconds
```

#### Duplicate Queries

[](#duplicate-queries)

To identify duplicate queries (queries with the same SQL statement and bindings), you can use the `duplicateQueries` method:

```
$duplicateQueries = QueryWatcher::duplicateQueries();
```

#### Assertions

[](#assertions)

The QueryWatcher package also provides assertion methods to facilitate testing. These methods allow you to assert whether certain conditions are met based on the executed queries.

- `assertHasDuplicateQueries`: Assert that duplicate queries were executed.
- `assertNoDuplicateQueries`: Assert that no duplicate queries were executed.
- `assertHasSlowQueries`: Assert that slow queries were executed.
- `assertNoSlowQueries`: Assert that no slow queries were executed.

Here's an example of using assertions in a test case:

```
public function test_queries()
{
    QueryWatcher::watch();

    // Code that executes queries

    QueryWatcher::assertNoDuplicateQueries();

    QueryWatcher::assertNoSlowQueries();
}
```

#### Contributing

[](#contributing)

If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository.

#### License

[](#license)

The QueryWatcher package is open-source software licensed under the MIT license.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~74 days

Recently: every ~92 days

Total

6

Last Release

771d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/70261356?v=4)[Huub](/maintainers/HuubVerbeek)[@HuubVerbeek](https://github.com/HuubVerbeek)

---

Top Contributors

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

---

Tags

eloquentfeature-testinglaravelphpunitqueriestestingframeworklaravelwatcherqueriesquery-watcher

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[pestphp/pest-plugin-laravel

The Pest Laravel Plugin

22754.8M11.6k](/packages/pestphp-pest-plugin-laravel)[lanin/laravel-api-debugger

Easily debug your JSON API.

2371.8M1](/packages/lanin-laravel-api-debugger)[pestphp/pest-plugin-drift

The Pest Drift Plugin

745.1M107](/packages/pestphp-pest-plugin-drift)[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

99600.5k8](/packages/defstudio-pest-plugin-laravel-expectations)[graham-campbell/testbench

TestBench Provides Some Testing Functionality For Laravel

50366.3k381](/packages/graham-campbell-testbench)[hemp/presenter

Easy Model Presenters in Laravel

247616.4k1](/packages/hemp-presenter)

PHPackages © 2026

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