Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Dump Sql Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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.

  • Correctness risk (medium). Binding interpolation is inherently string surgery. Quoting of strings, dates, booleans, 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.
  • Upgrade risk (medium). It reaches into query grammar / builder internals indirectly via 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).
  • Maintenance risk (high, by signal). 36 stars, a 0.3 composite score, single-maintainer profile, last release 2024-03-14. Bus factor is effectively one. There is no meaningful ecosystem pressure to keep it current.
  • Data-handling risk (high if uncontrolled). Inlining bindings means secrets (emails, tokens, PII) land in terminal output, log files, or CI artifacts. That is the single largest governance concern and is entirely a usage-policy problem, not a code problem.

Key questions for the maintainer/consumer.

  1. Which Laravel and PHP versions are actually supported and CI-tested, versus merely declared?
  2. Does interpolation handle our primary driver's quoting rules (MySQL vs. PostgreSQL vs. SQLite) — and do we use more than one?
  3. Does it degrade gracefully on subqueries, whereIn arrays, json columns, and raw expressions, or silently emit wrong SQL?
  4. Is there any built-in redaction/masking hook, or would we need to wrap it?
  5. Does Laravel's native toRawSql() (available in recent 10.x/11.x) cover our need, making the dependency redundant?
  6. Can we fork and vendor it (~100–200 LOC) if the maintainer goes dormant?

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.

Integration Approach

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.

  1. Week 1 — spike. One engineer installs it in a scratch branch, runs the matrix above, and records where interpolation is wrong.
  2. Week 1 — compare. Benchmark against native toRawSql(), DB::listen(), and Telescope's query view. If a native path is adequate, stop here; that is a valid and cheaper outcome.
  3. Week 2 — pilot. Offer it to one squad as an opt-in dev tool with a one-paragraph usage note. Gather whether it actually changes debugging speed.
  4. Week 3 — standardize or drop. If adopted: document it in the engineering handbook under "local debugging utilities," add the dev-only guardrail, and schedule a six-month review tied to the next Laravel major upgrade.
  5. Ongoing. Re-evaluate at every Laravel major version bump; the expected outcome within 12–18 months is replacement by native query-builder functionality.

Operational Impact

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.

  • Silently wrong SQL → treat output as illustrative, never paste into production; verify against the DB client for non-trivial queries.
  • Fatal error after a Laravel upgrade → it is dev-only, so blast radius is a broken local environment, not an outage; the fix is removal.
  • Secret/PII leakage into logs or CI artifacts → policy: local terminal only, no dumping queries built from real customer data, no enabling in shared environments.
  • Abandonment → fork the small codebase into an internal utilities package or replace with a native call.

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource