firehed/dbal-logger
A drop-in Doctrine DBAL logger that sends SQL queries and execution times to any PSR-3 logger, making database activity and slow queries easy to trace in PHP applications without extra instrumentation.
SQLLogger interface. Any product still relying on it during a DBAL 3 → 4 migration makes a real decision: rewrite query logging in-house, adopt an unmaintained shim, or adopt a small drop-in middleware like this one. This package is the lowest-effort path and directly de-risks that upgrade. Note that the 3.0.0 release adds its own breaking changes (see below), so treat the DBAL upgrade and the middleware upgrade as a single sequenced work item rather than two.laravel-doctrine, or a legacy Symfony/Doctrine codebase inside a Laravel monorepo), this package is a scoped, low-commitment way to restore SQL logging for debugging and profiling without standing up a full APM stack. 3.0.0 strengthens this: stopQuery() now receives the thrown exception, so failed queries can be logged and counted alongside successful ones — useful for failure-rate sanity checks and triage without a full metrics pipeline.DbalLogger contract to wrap instead of two.SQLLogger, this package buys time and unblocks upgrades without a parallel logging subsystem.Adopt when:
SQLLogger-style query logging after the DBAL 4 removal.stopQuery() exception argument lets you record errored queries without bolting on a separate error hook.Look elsewhere when:
DB::listen, query log, and Telescope already cover this — adding a DBAL middleware is unnecessary surface area.Adoption guardrails: pin the version, wrap it behind your own logging interface so it can be swapped, and confirm the maintainer's release/response cadence before relying on it in anything beyond dev/staging. If upgrading from 2.x, budget for the 3.0.0 breaking changes: PHP 8.2+ baseline, QueryLogger/DbalLogger merged into a single DbalLogger interface, added native type declarations on all interface methods, and an updated stopQuery() signature that now takes the exception. Any custom logger implementations must be updated in lockstep; check UPGRADING.md and lean on static analysis in CI to catch signature drift.
For executives: "We have a narrow, low-cost dependency choice that removes a known blocker in our database-layer upgrade. Doctrine's SQL logger was removed in a major version, and this small MIT-licensed package restores that capability as a drop-in middleware. It's free, scoped, and reversible — the risk is supplier concentration (one maintainer, minimal adoption), so we recommend restricting it to non-production environments and wrapping it behind our own interface. The new 3.0.0 release is actively maintained: it modernizes the interface, adds error-path logging, and drops end-of-life PHP 8.1. That activity is reassuring, but it also means a one-time upgrade cost and a PHP 8.2 minimum for the services that adopt it. Net effect: we unblock an upgrade without funding an in-house logging component."
For engineering leadership:
SQLLogger was removed in DBAL 4. Teams on Doctrine need a logging replacement or a custom wrapper.stopQuery(), so failed queries are loggable too, and consolidates the two logger interfaces into one simpler contract.QueryLogger/DbalLogger, adding native types, and requiring PHP 8.2+ — so plan a short migration window rather than a silent composer update.DB::listen (doesn't cover Doctrine paths), APM vendors (heavier, costly, overkill for this need).How can I help you explore Laravel packages today?