New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

fitztrev/query-tracer

Backtrace database queries
20,031 228
Install
composer require fitztrev/query-tracer
Latest Version:1.0.2
PHP:>=5.5.9
Laravel:5
License:MIT
Last Updated:May 22, 2016
Links: GitHub  ·  Packagist
Maintainer: fitztrev

Laravel Query Tracer

Build Status Latest Stable Version

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:

If you use Debugbar, it has this functionality built-in if you set debugbar.options.db.backtrace to true.

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?

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';
}

Related Packages

yadakhov/insert-on-duplicate-key

A trait for MySQL INSERT ON DUPLICATE KEY UPDATE.

3,117,053 275
audunru/eager-load-pivot-relations

Eager load pivot relations for Laravel Eloquent's BelongsToMany relation.

75,555 9
someonefamous/laravel-findby

Extended 'find' functionality for Eloquent (Laravel).

11,634 3
vluzrmos/eloquent-simple-searchable

An Eloquent Simple Searchable Scope.

201 2
hpolthof/laravel-eloquent-settings

Allow for dynamic blobbed settings in Eloquent models.

52 1

Version History

Version Released PHP Laravel License
1.0.2 >=5.5.9 ^5.2 MIT
1.0.1 >=5.5.9 ^5.2 MIT
1.0.0 >=5.6.4 MIT