PHPackages                             socialblue/laravel-query-adviser - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. socialblue/laravel-query-adviser

ActiveLibrary[Testing &amp; Quality](/categories/testing)

socialblue/laravel-query-adviser
================================

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.

3.3.2(2y ago)203.5k↓50%1[4 PRs](https://github.com/socialblue/laravel-query-adviser/pulls)MITVuePHP \*

Since Apr 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/socialblue/laravel-query-adviser)[ Packagist](https://packagist.org/packages/socialblue/laravel-query-adviser)[ Docs](https://github.com/socialblue/laravel-query-adviser)[ RSS](/packages/socialblue-laravel-query-adviser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (71)Used By (0)

Laravel-Query-Adviser
=====================

[](#laravel-query-adviser)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e0a606486a179d15791768f892a234a604948a0953f55ea1c03b908cb178083a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6369616c626c75652f6c61726176656c2d71756572792d616476697365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/socialblue/laravel-query-adviser)[![Quality Score](https://camo.githubusercontent.com/590066d29ef71c53e8b21aedb640a0215542a9d694a62a56e93ea6cdfdd24ef2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736f6369616c626c75652f6c61726176656c2d71756572792d616476697365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/socialblue/laravel-query-adviser)[![Total Downloads](https://camo.githubusercontent.com/c475348d8a8922d2ac4f44616d4b5f97e6ff8130f682dde657d42f00381fdae8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6369616c626c75652f6c61726176656c2d71756572792d616476697365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/socialblue/laravel-query-adviser)

  [![](./public/images/favicon.svg)](./public/images/favicon.svg) 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
--------

[](#features)

Query LoggingWeb appChrome DevToolCodeUse cache driverEloquent QueriesRoutesStack traceTinker SupportJob SupportMySql SupportStart sessionStart SessionStop sessionStop SessionExport SessionImport SessionQuery GroupingQuery OrderingExplain QueryRe-execute QueryCopy to clipboardShow realtime query usagedd query builder querydump query builder querydd eloquent model querydump eloquent model queryInstallation
------------

[](#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
-----------------------------

[](#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](https://chrome.google.com/webstore/detail/laravel-query-adviser/dgojkgibloeebbjieckfjaflodkamdbf).

[![Extension](./img/chrome-developer-tool.png)](./img/chrome-developer-tool.png)

Usage
-----

[](#usage)

### Output queries inline

[](#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

[](#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
>
> [](#session-stepper)
>
> [![Query Overview](./img/stepper.png)](./img/stepper.png)

> #### Session list
>
> [](#session-list)
>
> [![Query Overview](./img/session-list.png)](./img/session-list.png)

### Brows through session overview

[](#brows-through-session-overview)

> #### Query time-line
>
> [](#query-time-line)
>
> *collapse and expand the panels for less or more information about the queries executed in that time frame.*[![Query Overview](./img/overview.png)](./img/overview.png)

#### Groups

[](#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](img/group-by-new.png)](img/group-by-new.png)

#### Sort

[](#sort)

> *Sort the time line by last inserted, slowest query, and most occurrences*[![Query Card](./img/sorting.png)](./img/sorting.png)

#### Query card

[](#query-card)

> *Re-execute a query, get query information, and copy the query to your clipboard*[![Query Card](./img/card.png)](./img/card.png)

#### Query labels

[](#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](./img/labels.png)](./img/labels.png)

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

> *Query information*[![Query Card](./img/query-information.png)](./img/query-information.png)

> *Re-execute Query*[![Query Card](./img/query-execute.png)](./img/query-execute.png)

### Testing

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mark](https://github.com/socialblue)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

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

Total

61

Last Release

923d ago

Major Versions

0.15.0 → 1.0.02021-08-18

1.2.2 → 2.0.02022-09-23

2.3.2 → 3.0.02023-07-11

PHP version history (4 changes)v0.0.1PHP ^7.1

0.11.1PHP ^7.0

1.1.2PHP 8.\*

2.3.1PHP \*

### Community

Maintainers

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

---

Top Contributors

[![mbroersen](https://avatars.githubusercontent.com/u/2418774?v=4)](https://github.com/mbroersen "mbroersen (392 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")

---

Tags

advisordatabaseeloquentinsightslaravelmssqlmysqloptimizationperformanceperformance-analysispostgresqlquery-optimizationsqltestingtestinglaravelperformancemysqlsqlmssqleloquentqueryInsightsapplicationadvisorsocialbluelaravel-query-adviserjeloquent

###  Code Quality

Code StyleECS

### Embed Badge

![Health badge](/badges/socialblue-laravel-query-adviser/health.svg)

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

###  Alternatives

[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[imanghafoori/eloquent-mockery

Allows you to design your tests in an independent manner.

127636.4k2](/packages/imanghafoori-eloquent-mockery)[sarfraznawaz2005/indexer

Laravel package to monitor SELECT queries and offer best possible INDEX fields.

562.7k](/packages/sarfraznawaz2005-indexer)[sofa/eloquent-testsuite

Helpers for fast and reliable UNIT tests for your Eloquent Models with PHPUnit

10104.7k](/packages/sofa-eloquent-testsuite)

PHPackages © 2026

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