Skip to content

With Laravel Query Adviser you can get more insights into the SQL queries created by Eloquent models used in your app. It logs the queries used by your application and provides a helpful overview of the SQL queries. You can rerun the SQL query to analyze the database impact or copy the SQL query to your clipboard.

License

Notifications You must be signed in to change notification settings

socialblue/laravel-query-adviser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel-Query-Adviser

Latest Version on Packagist Quality Score Total Downloads

With Laravel Query Adviser you can get more insights into the SQL queries created by Eloquent models used in your app. It logs the queries used by your application and provides a helpful overview of the SQL queries. You can rerun the SQL query to analyze the database impact or copy the SQL query to your clipboard. The handy card view allows you to quickly point out the pain points of your application's SQL queries.

Features

Query Logging Web app Chrome DevTool Code
Use cache driver
Eloquent Queries
Routes
Stack trace
Tinker Support
Job Support
MySql Support
Start session Start Session
Stop session Stop Session
Export Session
Import Session
Query Grouping
Query Ordering
Explain Query
Re-execute Query
Copy to clipboard
Show realtime query usage
dd query builder query
dump query builder query
dd eloquent model query
dump eloquent model query

Installation

You can install the package via composer:

composer require socialblue/laravel-query-adviser --dev

Publish Laravel-Query-Adviser

php artisan vendor:publish --provider="Socialblue\LaravelQueryAdviser\LaravelQueryAdviserServiceProvider"

Publish the front-end application after updating

php artisan vendor:publish --tag=public --force

When updating from 0.13.2 to 0.14.0 please use

php artisan vendor:publish --provider="Socialblue\LaravelQueryAdviser\LaravelQueryAdviserServiceProvider" --force

Install Chrome developer tool

When you want to be able to start and stop the log sessions and see realtime query information from your current browser tab. You can install the Chrome developer tool in the Chrome web store.

Extension

Usage

Output queries inline

Dump and die

User::join('posts', 'posts.users_id', '=', 'users.id')
->select([DB::raw('SUM(posts.id)')])
->where('users.id', 1)
->select([DB::raw('SUM(post.id)')])->qadd();

or just dump

User::join('posts', 'posts.users_id', '=', 'users.id')
->select([DB::raw('SUM(posts.id)')])
->where('users.id', 1)
->select([DB::raw('SUM(post.id)')])->qadump();

both dump this array

[
   'toSql' => 'select sum(posts.id) from users join posts on posts.users_id = users.id where users.id = ?'
   'bindings' => [1]
   'query' => 'select sum(posts.id) from users join posts on posts.users_id = users.id where users.id = 1'
]

Start query logging session

  1. To start a query log session goto {app_url}/query-adviser/
  2. Press play and open the pages of your app you want to log the queries of
  3. Stop the session and click on the session bar to see all the details.

Session stepper

Query Overview

Session list

Query Overview

Brows through session overview

Query time-line

collapse and expand the panels for less or more information about the queries executed in that time frame. Query Overview

Groups

You can group the queries by time, routes and rawQuery. Also you can clear the cached queries by pressing the eject button.

group by time, routes, referer, raw queries, queries with bindings, and query time Query groups

Sort

Sort the time line by last inserted, slowest query, and most occurrences Query Card

Query card

Re-execute a query, get query information, and copy the query to your clipboard Query Card

Query labels

As of version 0.10.0, the query card has labels related to the class, file and function of the query executed from your app folder.

File Information Query labels

Open the explain dialog to see more information about the query.

Query information Query Card

Re-execute Query Query Card

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mark.broersen@outlook.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

About

With Laravel Query Adviser you can get more insights into the SQL queries created by Eloquent models used in your app. It logs the queries used by your application and provides a helpful overview of the SQL queries. You can rerun the SQL query to analyze the database impact or copy the SQL query to your clipboard.

Topics

Resources

License

Stars

Watchers

Forks

Packages