guanguans/laravel-dump-sql
Laravel package that reveals the real SQL behind your query builder and Eloquent queries. It adds dumpSql() and ddSql() macros so you can print or dump fully interpolated SQL, bindings included, plus helpers for logging queries—making database debugging faster and clearer.
toRawSql()/ddRawSql() (available in Laravel 10.x+/11+). The decision hinges on your Laravel version and how much you value the dumpSql()/ddSql() macro ergonomics over framework-native parity.require-dev while holding production dependencies to a stricter bar.Use cases: tinker exploration, artisanal one-off scripts, onboarding engineers to an unfamiliar schema, debugging queued jobs and raw query builder code, and reproducing Eloquent-generated SQL during code review.
Consider it when:
toSql() still returns ? placeholders and you want bindings inlined without hand-interpolating.dumpSql()/ddSql() macros on the query builder inside an existing Laravel app rather than a separate debugging service.require-dev only.Look elsewhere when:
toRawSql()/ddRawSql() already covers the need — adoption cost likely exceeds the marginal benefit.For executives: A free, MIT-licensed, developer-only utility that lets engineers see the exact SQL their application sends to the database — complete, with values filled in — instead of a placeholder-filled approximation. It costs nothing to license, requires no infrastructure, and never ships to production; it is installed as a development dependency only. The business value is time: faster debugging of data bugs, faster reproduction of customer-reported issues, and faster onboarding onto an unfamiliar schema. The risk is equally small and bounded — one small third-party package, confined to development and testing environments, with no runtime exposure to customers. Recommendation: trial it on one team, keep it out of production dependencies, and revisit if the framework's built-in equivalent makes it redundant.
For engineering: composer require --dev guanguans/laravel-dump-sql, then ->dumpSql() / ->ddSql() on the query builder in tinker, a command, or a test. It saves the manual ?-to-binding interpolation step and the "add DB::listen and dump" ritual. Two caveats: (1) it overlaps with Laravel's native toRawSql(), so check your version before adding a dependency; (2) inlined bindings mean real data in output — keep it local, never in shared CI logs or production, and pin the version since the project is small and lightly maintained. If you already run Telescope or Debugbar, treat this as a scratchpad, not a replacement for profiler-grade observability.
How can I help you explore Laravel packages today?