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.
What it is. guanguans/laravel-dump-sql is a developer-experience package, not runtime infrastructure. It registers a service provider that exposes macros on the query builder / Eloquent builder (e.g. dumpSql() / ddSql()) which render the complete SQL by inlining bound parameters into the toSql() output, then dumping or dying. It solves one narrow, real friction point: Laravel's toSql() returns ? placeholders, forcing developers to hand-substitute bindings while debugging.
Architecture fit. Good in principle. It is a zero-configuration, auto-discovered Laravel package (service provider + macros), with no database driver, queue, cache, or event-loop footprint. It can be confined entirely to require-dev, meaning it never enters the production dependency graph or the deployed artifact. Architecturally it is a leaf node — nothing depends on it, and removing it changes no application behavior.
Integration feasibility. Low effort. A single composer require --dev plus auto-discovery; no config publishing, no migrations, no credentials. Verification is a one-line smoke test in tinker against a known query. The only real gating factor is verifying the package's composer.json constraints against our PHP and Laravel versions.
Technical risk.
null, binary data, and expressions is heuristic; deeply nested subqueries, whereIn with large arrays, having, unions, and raw expressions are the classic failure points. Output can be plausible but not executable — dangerous if someone pastes it into a production console.toSql() and getBindings(), which are relatively stable, but macros registered on builder classes are sensitive to Laravel major-version refactors (e.g. the introduction of native toRawSql() on the query builder reduces the package's reason to exist).Key questions for the maintainer/consumer.
whereIn arrays, json columns, and raw expressions, or silently emit wrong SQL?toRawSql() (available in recent 10.x/11.x) cover our need, making the dependency redundant?Assessment. Technically sound and cheap, strategically marginal. Adopt only as an optional dev convenience with an explicit "never in production, never with real PII" rule, or skip it and standardize on native toRawSql() / Telescope / a 30-line internal macro.
Stack fit. Ideal for a standard Laravel monolith or modular monolith on a single RDBMS, used by backend engineers in local and CI-debug contexts. It fits poorly where multiple database engines coexist (quoting semantics diverge) or where developers work primarily through an IDE/DB client and rarely need inline SQL.
Placement. require-dev only, committed to composer.json and pinned in composer.lock. It must not appear in the production build's --no-dev install. If our deployment pipeline ships the vendor directory from a dev install, add an explicit exclusion check.
Migration path. Effectively zero-cost in both directions: install is one composer command, removal is one composer remove --dev plus a lockfile update. Nothing in application code should ever depend on it — no tests asserting on its output, no runtime branches. That reversibility is its main virtue and should be stated as the adoption rationale.
Compatibility. Build a small matrix before rollout: PHP version(s) in use × Laravel version(s) in use × database driver(s). Verify against one Eloquent query with bindings of each scalar type, one whereIn, one nested subquery, and one raw expression. Treat any rendering discrepancy as a blocker for team-wide recommendation.
Sequencing.
toRawSql(), DB::listen(), and Telescope's query view. If a native path is adequate, stop here; that is a valid and cheaper outcome.Maintenance. Near-zero for consuming teams; the burden sits with the package author, and that is precisely the risk. No config to drift, no schema, no runtime surface. Budget roughly one hour per Laravel major upgrade to confirm the macros still register and render correctly — and a standing contingency to fork or delete.
Support. Community-only, single maintainer, bilingual (Chinese/English) documentation of modest depth. Internal support should be "ask the platform team, or fall back to Telescope." Do not let it become load-bearing in onboarding materials without a documented fallback.
Scaling. Irrelevant at runtime — it executes only when a developer calls the macro. The scaling concern is human and informational: verbose SQL dumps in shared CI logs or chat channels are noisy, and the package does not redact by default. If it is ever invoked in an automated context, cap output size (large whereIn lists produce enormous strings) and never enable it behind a web route.
Failure modes and mitigations.
Ramp-up. Minutes. Any Laravel developer who understands toSql() grasps the value immediately; the only training needed is the guardrail ("dev-only, never with production data"). Documentation cost is one paragraph, not a runbook. Onboarding impact is therefore negligible — which is also the honest measure of the package's strategic weight: it is a convenience, and should be governed like one.
How can I help you explore Laravel packages today?