Download the PHP package jeytekdev/explain-lint-laravel without Composer
On this page you can find all versions of the php package jeytekdev/explain-lint-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeytekdev/explain-lint-laravel
More information about jeytekdev/explain-lint-laravel
Files in jeytekdev/explain-lint-laravel
Package explain-lint-laravel
Short Description Laravel bridge for jeytekdev/explain-lint — captures queries via DB::listen() and provides a service provider with auto-discovery.
License MIT
Homepage https://github.com/jeytekdev/explain-lint-laravel
Informations about the package explain-lint-laravel
jeytekdev/explain-lint-laravel
Laravel bridge for jeytekdev/explain-lint — re-runs EXPLAIN against every query your test suite executes, and fails the build on full table scans, lost indexes, filesort and temporary tables.
Install (2 minutes)
The service provider auto-discovers via extra.laravel.providers — nothing to register manually. It hooks DB::listen() and only captures queries while $app->runningUnitTests() is true (or EXPLAIN_LINT_FORCE=true), so there's no overhead outside your test suite.
Wire up the PHPUnit extension:
Run this from your project root (where composer.json/vendor/ live) — every path it touches (phpunit.xml, the new explain-lint.php) is resolved relative to the current working directory, not to vendor/bin/.
Or add it manually to phpunit.xml:
Set the connection driver to match your database in the generated explain-lint.php:
Then run your suite as usual — no other code changes needed:
Reading the report
A violation is printed as a block, grouped by test, with the info needed to act on it — including the fingerprint you'd copy into an allowlist entry:
- In
mode => 'warn'this is informational only — the build stays green. - In
mode => 'strict', any[error]-severity violation fails the run.
Allowlisting a known-OK query
Two ways, both in explain-lint.php, both require a non-empty reason:
Optional: per-test assertions
If you'd rather assert explicitly inside a specific test instead of relying on suite-wide enforcement (or you're on a PHPUnit version predating the Extension/Event API), use the testing trait:
CI
Relying solely on the in-process exit(1) from the PHPUnit run is a single point of failure if anything in your pipeline swallows PHPUnit's exit code — run the check as a separate second step:
explain-lint:check needs a JUnit report to read, so enable it in config:
Troubleshooting
A table with very few rows still gets flagged as error. Table-size-based suppression (tiny/small tables never trigger scan rules) relies on information_schema.TABLES.TABLE_ROWS on MySQL, which is a cached estimate — on a freshly migrated test database it's often NULL until ANALYZE TABLE runs, and an unknown size is treated as "could be large" on purpose (so real regressions aren't silently hidden by a stale stat). If this shows up a lot on your test DB, either run ANALYZE TABLE <name> as part of your test setup, or allowlist the specific table/query.
Could not locate the Composer autoloader when running vendor/bin/explain-lint. If the package was installed via a path repository, vendor/jeytekdev/explain-lint is a symlink — this is resolved correctly as of the current release, but if you're on an older checkout, update jeytekdev/explain-lint.
Connection resolution. DB::listen() fires with the query's connectionName, matched against connections.<name> in your config, falling back to connections.default if there's no exact match — you don't need one entry per Laravel connection unless you actually want different thresholds per connection.
License
MIT
All versions of explain-lint-laravel with dependencies
jeytekdev/explain-lint Version ^1.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0
illuminate/support Version ^10.0 || ^11.0 || ^12.0