PHPackages                             mdj/db-optimizer-agent - 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. mdj/db-optimizer-agent

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

mdj/db-optimizer-agent
======================

Laravel DB query optimizer agent and scanner dashboard for local/staging.

v2.0.0(1mo ago)028↓87.5%MITPHPPHP ^8.1

Since Mar 25Pushed 1mo agoCompare

[ Source](https://github.com/mahmudursany/db-optimizer-agent)[ Packagist](https://packagist.org/packages/mdj/db-optimizer-agent)[ RSS](/packages/mdj-db-optimizer-agent/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (25)Used By (0)

mdj/db-optimizer-agent
======================

[](#mdjdb-optimizer-agent)

Laravel 11 package for local/staging database query diagnostics.

Compatibility
-------------

[](#compatibility)

- PHP `8.1+`
- Laravel `8.x`, `9.x`, `10.x`, or `11.x`

Install note:

- Composer will resolve dependencies based on your project's existing Laravel major version.

Features
--------

[](#features)

- `DB::listen` query interception
- N+1 suspicion signals
- Missing index hints from `WHERE` / `JOIN`
- Auto `EXPLAIN` on slow queries
- Cache candidate hints
- Advanced optimization suggestions with code hints
- Rewritten "New Query" suggestions shown under detected queries
- Executable guarded SQL for index suggestions (safe to rerun)
- Laravel-style current and optimized query snippets for direct copy/paste
- Optional safe auto-apply eligibility flags
- Built-in dashboard + remote scanner + protected agent API

Install in another Laravel project (local path)
-----------------------------------------------

[](#install-in-another-laravel-project-local-path)

1. In target project `composer.json`, add local repository:

```
{
	"repositories": [
		{
			"type": "path",
			"url": "../db-optimizer-tool/packages/db-optimizer-agent",
			"options": {
				"symlink": true
			}
		}
	]
}
```

2. Require package:

```
composer require mdj/db-optimizer-agent:* --dev
```

3. Publish config:

```
php artisan vendor:publish --tag=db-optimizer-config
```

4. Set `.env`:

```
DB_OPTIMIZER_ENABLED=true
DB_OPTIMIZER_AGENT_TOKEN=change-me
DB_OPTIMIZER_ROUTE_PREFIX=_db-optimizer
DB_OPTIMIZER_CAPTURE_TESTING=false
DB_OPTIMIZER_REGISTER_DASHBOARD_ROUTES=true
DB_OPTIMIZER_REGISTER_AGENT_ROUTES=true
DB_OPTIMIZER_ADVANCED_SUGGESTIONS=true
DB_OPTIMIZER_AUTO_APPLY_SAFE=false
DB_OPTIMIZER_RECOMMENDATION_LIMIT=8
```

5. Visit dashboard:

`http://your-app.test/_db-optimizer`

Install from Git/Packagist
--------------------------

[](#install-from-gitpackagist)

After publishing package to GitHub + Packagist:

```
composer require mdj/db-optimizer-agent --dev
php artisan vendor:publish --tag=db-optimizer-config
```

Agent API
---------

[](#agent-api)

- `GET /_db-optimizer/agent/ping`
- `GET /_db-optimizer/agent/snapshots`
- `POST /_db-optimizer/agent/reset`

Send `Authorization: Bearer `.

Notes
-----

[](#notes)

- Use in local/staging first.
- Keep `DB_OPTIMIZER_ENABLED=false` in production unless you intentionally sample traffic.
- For existing projects with route conflicts, change `DB_OPTIMIZER_ROUTE_PREFIX`.
- If you only want scanner API, set `DB_OPTIMIZER_REGISTER_DASHBOARD_ROUTES=false`.
- Safe auto-apply only marks eligible suggestions; it does not rewrite your code automatically.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance89

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity52

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

Every ~1 days

Total

24

Last Release

56d ago

Major Versions

v1.4.7 → v2.0.02026-04-29

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.0.1PHP ^8.1

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/mdj-db-optimizer-agent/health.svg)

```
[![Health](https://phpackages.com/badges/mdj-db-optimizer-agent/health.svg)](https://phpackages.com/packages/mdj-db-optimizer-agent)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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