Repolode
halilcosdu

halilcosdu/laravel-slower

A Laravel package that captures slow database queries, groups repeats, and uses an LLM to suggest indexes and query rewrites, with a built-in dashboard.

Stars
415
Forks
22
Open issues
1
Last commit
19 days ago

What is it?

Laravel Slower hooks into Laravel's query listener and records every query that exceeds a configurable millisecond threshold, along with its bindings, connection, and the route, job, or artisan command that triggered it. Repeated statements are fingerprinted into groups so the most frequent slow shapes surface first.

Optionally, each captured query can be sent to an LLM (OpenAI, Anthropic Claude, Google Gemini, or a self-hosted or custom model through Prism) together with the parameterized SQL, table schema, indexes, and a read-only EXPLAIN plan. The returned advice on indexes and rewrites is stored and rendered as markdown. By default only parameterized SQL leaves the application; raw SQL and bindings require explicit opt-in and can be passed through a redactor.

The package ships a self-contained dashboard at /slower, gated to the local environment by default. It supports sampling, per-execution capture caps, queued analysis jobs, and events for alerting, and is installed through Composer with two migration steps.

Key features

  • 01Captures queries slower than a configurable threshold via a DB::listen hook.
  • 02Groups repeated query shapes by fingerprint with occurrence counts and durations.
  • 03Records the route, controller action, job, or command and code location that triggered each query.
  • 04Sends parameterized SQL and schema context to OpenAI, Anthropic, Gemini, or custom drivers for recommendations.
  • 05Provides a built-in dashboard with search, filters, and one-click AI analysis.
  • 06Offers sampling, per-request caps, and queued background analysis.

Use cases

  • Finding the most frequent slow queries in a Laravel app during performance tuning.
  • Getting index and query rewrite suggestions without manually running EXPLAIN on each statement.
  • Alerting the team when a new slow query shape appears in production.
  • Keeping slow query logs running under heavy traffic with sampling and caps.

Quick start

  1. 1

    Install the package with Composer

    composer require halilcosdu/laravel-slower
  2. 2

    Publish the migrations

    php artisan vendor:publish --tag="slower-migrations"
  3. 3

    Run the migrations, then open /slower in your local environment

    php artisan migrate

Things to know

  • Requires PHP 8.3+ and Laravel 11, 12 or 13.
  • AI recommendations need an API key from a paid LLM provider, and each analysis is a billable call.
  • By default the dashboard is only accessible in the local environment until you define a viewSlower gate.

In collections

Topics

FAQ

What is laravel-slower?
A Laravel package that captures slow database queries, groups repeats, and uses an LLM to suggest indexes and query rewrites, with a built-in dashboard. Laravel Slower hooks into Laravel's query listener and records every query that exceeds a configurable millisecond threshold, along with its bindings, connection, and the route, job, or artisan command that triggered it. Repeated statements are fingerprinted into groups so the most frequent slow shapes surface first.
Is laravel-slower free to use? What license does it have?
laravel-slower is open source under the MIT license. Check the license terms before using it in commercial products.
Is laravel-slower still maintained?
Actively maintained. The last commit to laravel-slower was on Oct 19, 2026.
What can I use laravel-slower for?
Finding the most frequent slow queries in a Laravel app during performance tuning. Getting index and query rewrite suggestions without manually running EXPLAIN on each statement. Alerting the team when a new slow query shape appears in production. Keeping slow query logs running under heavy traffic with sampling and caps.
How do I install laravel-slower?
Install the package with Composer: composer require halilcosdu/laravel-slower Publish the migrations: php artisan vendor:publish --tag="slower-migrations" Run the migrations, then open /slower in your local environment: php artisan migrate
Where can I get laravel-slower?
The source code and installation instructions are on GitHub: https://github.com/halilcosdu/laravel-slower

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects