- Can I install this bundle in a Laravel application?
- Not as a working dependency. halloverden/symfony-doctrine-sql-logger-bundle is a Symfony bundle that registers services through a Symfony kernel and DI extension, so Composer will install it but nothing will load in a Laravel app. Treat it as a reference implementation and port the formatting logic into a Laravel service provider if the technique is useful. Laravel version constraints only matter for that port, where Laravel 10 and 11 on PHP 8.1+ are the reasonable targets.
- How do I log SQL queries with bound parameters in Laravel?
- Use DB::listen and type-hint the QueryExecuted event, then interpolate the query bindings into the SQL string with proper quoting for strings, dates, nulls, and arrays used by whereIn. Register the listener in a dedicated service provider that can be toggled per environment, and send the result through Laravel's logger with a clear channel. The bundle's parameter-binding routine is a good reference for handling types correctly.
- What is the Laravel equivalent of this Symfony SQL logger bundle?
- Laravel ships DB::listen and the QueryExecuted event, which provide the same hook the bundle uses in Doctrine. For ready-made tooling, Laravel Telescope and barryvdh/laravel-debugbar show queries with bindings during development. If you need production-grade structured query logs, a small in-house listener is usually better than adopting a Symfony bundle.
- Does this bundle use Doctrine SQLLogger or the newer DBAL middleware?
- This is the first thing to verify in the source before relying on it. Doctrine DBAL 3 deprecated SQLLogger and DBAL 4 removed it in favor of middleware, so a bundle whose history centers on a SQL logger may target the deprecated API. Check the composer constraints and the classes it implements; if it is SQLLogger-based, use the middleware approach instead when porting.
- Is it safe to log interpolated SQL parameters in production?
- It is risky by default. Parameter interpolation is the bundle's core feature and its core hazard, because emails, tokens, and card fragments get written to logs verbatim. Any production use needs a redaction or allowlist layer, plus retention and access controls on the log channel. Many teams keep full parameter logging in development only.
- How can I redact sensitive data before writing SQL queries to logs?
- Wrap the interpolation step in a formatter that checks each binding against a deny list of column names or value patterns, and replace matches with a placeholder before logging. Keep the raw formatter available for local debugging but default to the redacted one outside local. The bundle itself should be assumed to log raw values unless the source shows a redaction hook.
- Can I use this bundle if I run Doctrine through laravel-doctrine/orm?
- You still cannot load the Symfony bundle directly, but the underlying technique can be reimplemented. Register the formatter as a Doctrine DBAL middleware in a Laravel service provider rather than as a SQLLogger, and keep it behind a config toggle. That gives you query and parameter logging for Doctrine entities while staying inside Laravel's container.
- How much performance overhead does SQL query logging with backtraces add?
- Interpolating every query and capturing a caller backtrace is expensive in hot paths and can multiply log I/O and spend. The bundle's log-level heuristics and backtrace depth should be treated as configurable costs, not free features. Enable it for local or sampled traffic, and benchmark before turning it on in production.
- Is halloverden/symfony-doctrine-sql-logger-bundle actively maintained?
- The public signals are weak: around three stars, no dependents, and a single-maintainer profile. Check the last commit date, open issues, and DBAL version constraints before depending on it. At this adoption level, vendor the formatting class under your own namespace with MIT attribution instead of adding it as an external dependency.
- How do I test that my Laravel query logger works?
- Use Log::spy or a fake log channel, run a query with known bindings, and assert the expected interpolated SQL and context were written. Cover edge cases such as null, booleans, dates, and whereIn arrays, plus the redaction rules. Feature tests on an in-memory SQLite connection are enough for the listener wiring.