PHPackages                             endeavour-agency/laravel-query-insights - 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. endeavour-agency/laravel-query-insights

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

endeavour-agency/laravel-query-insights
=======================================

This packages aims to provide insights into performed queries. Multiple handlers exist to control what should be done with the query data.

0.1.0(1y ago)1899MITPHPPHP ^8.2CI failing

Since Nov 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/endeavour-agency/laravel-query-insights)[ Packagist](https://packagist.org/packages/endeavour-agency/laravel-query-insights)[ Docs](https://github.com/endeavour-agency/laravel-query-insights)[ RSS](/packages/endeavour-agency-laravel-query-insights/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Laravel Query Insights
======================

[](#laravel-query-insights)

This package aims to provide query insights. By default, it comes with two handlers:

- `LogHandler`: Writes the executed queries to a log file
- `LighthouseResponseHandler`: Adds the executed queries to the extensions section of a [Lighthouse](https://lighthouse-php.com/) GraphQL response.

Getting started
---------------

[](#getting-started)

To get started, simply install the package.

```
composer require endeavour-agency/laravel-query-insights
```

Then, in a service provider, register the desired handlers with the `QueryCollectorInterface`.

```
public function register(): void
{
    $collector = $this->app->make(QueryCollectorInterface::class);

    $collector
        ->registerHandler(
            $this->app->make(LogHandler::class),
        )
        ->registerHandler(
            $this->app->make(LighthouseResponseHandler::class),
        );
}
```

Configuration
-------------

[](#configuration)

The package comes with a configuration file which can be published through

```
php artisan vendor:publish --provider=EndeavourAgency\\LaravelQueryInsights\\Providers\\LaravelQueryInsightsProvider

```

Through the configuration file, the insights can be enabled or disabled. By default, insights will only be enabled if `config('app.debug')` evaluates to `true`.

Alternatively, insights can be enabled or disabled through the `QUERY_INSIGHTS_ENABLED` env variable.

Handlers
--------

[](#handlers)

The package bundles a few handlers to get you started quickly.

### Log handler

[](#log-handler)

The log handler will log all executed queries to a log file. It accepts an instance of the `Psr\Log\LoggerInterface`. By default, it will log the queries to the default log channel (`config('logging.default')`).

**Example log handler output:**

```
[2024-11-08 14:27:30] local.INFO: Queries: POST http://localhost:8000/graphql {"queries":[{"query":"select * from `users` where `email` = 'john@doe.com' and `users`.`deleted_at` is null limit 1","sql":"select * from `users` where `email` = ? and `users`.`deleted_at` is null limit 1","bindings":["john@doe.com"],"time":1.54}]}
[2024-11-08 14:27:31] local.INFO: Queries: POST http://localhost:8000/graphql {"queries":[{"query":"select * from `users` where `email` = 'jane@doe.com' and `users`.`deleted_at` is null limit 1","sql":"select * from `users` where `email` = ? and `users`.`deleted_at` is null limit 1","bindings":["jane@doe.com"],"time":1.51}]}

```

### Lighthouse Response Handler

[](#lighthouse-response-handler)

The Lighthouse response handler will add executed queries to the extensions section of the GraphQL responses bodies, when using [Lighthouse](https://lighthouse-php.com/).

**Example Lighthouse response handler output:**

```
{
  "data": {
    "me": {
      "email": "john@doe.com"
    }
  },
  "extensions": {
    "queries": [
      {
        "query": "select * from `oauth_access_tokens` where `id` = '******' limit 1",
        "sql": "select * from `oauth_access_tokens` where `id` = ? limit 1",
        "bindings": [
          "******"
        ],
        "time": 1.51
      },
      {
        "query": "select * from `users` where `id` = '17' and `users`.`deleted_at` is null limit 1",
        "sql": "select * from `users` where `id` = ? and `users`.`deleted_at` is null limit 1",
        "bindings": [
          "17"
        ],
        "time": 0.45
      }
    ]
  }
}
```

### Custom handlers

[](#custom-handlers)

To create your own handler, simply create a class that implements the `EndeavourAgency\LaravelQueryInsights\Contracts\HandlerInterface`interface. Then, register it like you would with the default handlers (see [Getting started](#getting-started)).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

602d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48a35604e924d56a81bff335b7e1f2dce0fb905b86e379f804207dbb956b9b40?d=identicon)[denniskoster](/maintainers/denniskoster)

---

Tags

loglaravelgraphqldatabasequeryquerieslighthouse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/endeavour-agency-laravel-query-insights/health.svg)

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[tpetry/laravel-query-expressions

Database-independent Query Expressions as a replacement to DB::raw calls

361609.7k3](/packages/tpetry-laravel-query-expressions)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[sarfraznawaz2005/meter

laravel package to find performance bottlenecks in your laravel application.

2498.2k](/packages/sarfraznawaz2005-meter)[muhdfaiz/laravel-tail-db

Provide artisan command to monitor realtime database query executed from the application. Able to automatically run explain command for each of query received.

5827.2k](/packages/muhdfaiz-laravel-tail-db)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)

PHPackages © 2026

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