PHPackages                             fitztrev/query-tracer - 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. fitztrev/query-tracer

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

fitztrev/query-tracer
=====================

Backtrace database queries

1.0.2(9y ago)23020.0k↓100%5[2 issues](https://github.com/fitztrev/query-tracer/issues)MITPHPPHP &gt;=5.5.9

Since May 9Pushed 9y ago5 watchersCompare

[ Source](https://github.com/fitztrev/query-tracer)[ Packagist](https://packagist.org/packages/fitztrev/query-tracer)[ RSS](/packages/fitztrev-query-tracer/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Laravel Query Tracer
--------------------

[](#laravel-query-tracer)

[![Build Status](https://camo.githubusercontent.com/9a4462428a432b6cbcffb3a8d398b815ff3ec80dc8e14febb48aef17183a7790/68747470733a2f2f7472617669732d63692e6f72672f6669747a747265762f71756572792d7472616365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fitztrev/query-tracer) [![Latest Stable Version](https://camo.githubusercontent.com/8f5b9c252599f673856d069df03d9c8b5529e21e380c2cb4bfd444e2fedbcc3b/68747470733a2f2f706f7365722e707567782e6f72672f6669747a747265762f71756572792d7472616365722f762f737461626c65)](https://packagist.org/packages/fitztrev/query-tracer)

Find exactly *where* a specific database query is being called in your Laravel application.

Want to optimize or debug your database queries but not sure where they're being called? See how it works below with [Clockwork](https://github.com/itsgoingd/clockwork):

[![](https://camo.githubusercontent.com/710fbf127a0395ffa8646535464669195bbb64dd6486f0916254063cf8d26069/687474703a2f2f692e696d6775722e636f6d2f306352733754552e706e67)](https://camo.githubusercontent.com/710fbf127a0395ffa8646535464669195bbb64dd6486f0916254063cf8d26069/687474703a2f2f692e696d6775722e636f6d2f306352733754552e706e67)

If you use [Debugbar](https://github.com/barryvdh/laravel-debugbar), it has this functionality built-in if you set `debugbar.options.db.backtrace` to `true`.

### Installation

[](#installation)

1. Install via composer:

    ```
    composer require fitztrev/query-tracer
    ```
2. Add the service provider to your `config/app.php`:

    ```
    'providers' => [
        // ...
        Fitztrev\QueryTracer\Providers\QueryTracerServiceProvider::class,
    ],
    ```

### How does it do it?

[](#how-does-it-do-it)

It makes use of Laravel's global query scopes to do a backtrace and find where a query originated. Then it puts that info in extraneous but helpful `WHERE` clauses.

By default, it's only enabled when `debug` is on. You can change this behavior for specific models by adding an `enableQueryTracer()` method to your model(s). For example:

```
public function enableQueryTracer()
{
    return config('app.env') == 'local';
}
```

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~7 days

Total

3

Last Release

3592d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.4

1.0.1PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/e335f6525d771af23ad9d80e451163e62239e087abffda9e2071c3d8573bfc5f?d=identicon)[fitztrev](/maintainers/fitztrev)

---

Top Contributors

[![fitztrev](https://avatars.githubusercontent.com/u/271432?v=4)](https://github.com/fitztrev "fitztrev (7 commits)")[![percymamedy](https://avatars.githubusercontent.com/u/11259669?v=4)](https://github.com/percymamedy "percymamedy (1 commits)")

---

Tags

laraveldebugdatabaseeloquent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fitztrev-query-tracer/health.svg)

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

###  Alternatives

[betterapp/laravel-db-encrypter

Provides database model attribute encryption/decryption

365604.2k8](/packages/betterapp-laravel-db-encrypter)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3410.3k3](/packages/wayofdev-laravel-cycle-orm-adapter)[weebly/laravel-mutate

Mutate Laravel attributes

1354.2k](/packages/weebly-laravel-mutate)[boaideas/laravel-cli-create-user

An artisan command to create, list and remove users in a laravel application from the cli

1610.7k](/packages/boaideas-laravel-cli-create-user)

PHPackages © 2026

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