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

Query Guard Laravel Package

alex-frolov/query-guard

Query Guard adds configurable safeguards to Laravel database queries, helping detect and block dangerous or unintended SQL before it reaches production. Enforce safety rules, catch destructive statements, and protect critical data with minimal setup.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

  • Architecture fit: The package is a development/CI-time query analysis tool, not a production runtime dependency. It fits naturally as a pre-merge or nightly quality gate in a Laravel/PHP application, especially where the data layer uses Doctrine DBAL/ORM or raw SQL. It detects query-in-loop patterns (N+1-style behaviour), missing-index risks, and tier 2 plan issues. For Eloquent-heavy Laravel apps, the fit is less certain: the release notes specifically mention Doctrine flush(), Doctrine paginator tables, and DBAL savepoints, so a TPM should confirm whether Eloquent query-builder patterns are covered or only adjacent DBAL traffic.
  • Integration feasibility: Straightforward for a PHP project: add as a dev dependency, run during the test/CI phase, generate a baseline with QUERY_GUARD_GENERATE_BASELINE=1, commit the baseline, and then fail builds on new findings. The package already supports baseline suppression and JSON reporting, which are the two mechanisms a TPM needs to introduce it without blocking all delivery on day one. ParaTest is supported, but the release notes clarify that parallel workers suppress console output and findings land only in report-json, so CI must parse the JSON artifact rather than scrape stdout.
  • Technical risk: Medium, concentrated in behaviour changes rather than API breakage. v1.0.1 says no public API changed, but query fingerprints changed for multi-row VALUES and the number of findings moves in both directions. Existing baselines will not match after upgrade: old entries can report as matching nothing, and tier 2 now checks tables inside subqueries, which can create new findings. Teams using fail-on="error" with tier 2 enabled should expect the first post-upgrade run to be noisy. There is also a false-negative risk on DBAL 3 without savepoints: query-in-loop cannot distinguish nested flushes under a test transaction, so a real flush() in a loop can be missed unless doctrine.dbal.use_savepoints: true is set. DBAL 4 is unaffected.
  • Key questions:
    • Does the package analyse Eloquent/query-builder traffic, or only Doctrine DBAL/ORM and raw SQL?
    • Which database engines and versions are supported for tier 2 plan analysis (MySQL is explicit in the notes; PostgreSQL/SQLite coverage is unclear)?
    • Does tier 2 require a live database connection, and what is the runtime overhead on a large test suite?
    • Is the report-json schema stable and documented? Can a TPM rely on it for dashboards and trend reporting?
    • How are baselines scoped — per branch, per environment, or per database engine?
    • What is the support and release cadence for the package, and is there a documented compatibility matrix for PHP, Laravel, Doctrine DBAL, and ParaTest?
    • For Laravel apps that do not use Doctrine, is the package still useful, or does it mostly duplicate Laravel-specific tooling such as Telescope, Debugbar, or query logging?

Integration Approach

  • Stack fit: Good fit for PHP projects with Doctrine DBAL/ORM, raw SQL, or a mixed data layer. For a Laravel application, the TPM should confirm whether the main query surface is Eloquent or Doctrine before treating this as a broad query-quality gate. If the app is Eloquent-first, run a time-boxed pilot on a service that uses Doctrine or raw SQL and measure finding relevance before wider rollout.
  • Migration path: Treat v1.0.1 as a baseline-breaking upgrade, not a drop-in patch. The practical path is: upgrade the package, regenerate the baseline with QUERY_GUARD_GENERATE_BASELINE=1, review the diff in findings, commit the new baseline, and only then re-enable CI enforcement. Teams on DBAL 3 should set doctrine.dbal.use_savepoints: true in test configuration before trusting query-in-loop results. Teams using ParaTest should update CI scripts to consume report-json rather than console output.
  • Compatibility: No public API change, so application code and CI command structure should remain intact. The compatibility issues are operational: changed fingerprints invalidate baselines, tier 2 now produces additional findings from subquery tables, and DBAL 3 test setups can silently miss looped flushes. The release also corrects a README claim about parallel worker summaries, so existing CI documentation that expected per-worker stdout should be revised.
  • Sequencing: Start with a single service and a non-blocking run. Generate a baseline, inspect the noisiest rules, and fix or consciously accept the highest-value findings. Then enable fail-on="error" for new findings only, keeping the baseline as a ratchet. Turn on tier 2 separately and compare the first run against the tier 2-off baseline, because tier 2 both adds subquery coverage and changes how plan failures are counted. Finally, roll the pattern to additional services once the baseline workflow and JSON reporting are proven.

Operational Impact

  • Maintenance: Low ongoing maintenance for a dev-only package, but the baseline becomes a maintained artifact. Fingerprint changes mean baselines must be regenerated on some upgrades, and the TPM should expect a small amount of churn at each release. The package’s own release notes are explicit about baseline regeneration, which is a good sign for operability, but the team still needs an owner for baseline review.
  • Support: The v1.0.1 notes materially improve supportability by reducing false positives from misread input. The query-in-loop change around Doctrine flush() and savepoints is particularly important: it turns a confusing false positive into either a correct finding or an explicit notice. The corrected README note about ParaTest output prevents a common CI-support trap. Remaining support burden is mostly developer education around baseline regeneration and interpreting tier 2 plan results.
  • Scaling: The package is designed to run in parallel test environments, but scaling depends on CI parsing report-json rather than console logs. Tier 2 plan analysis may add cost on large suites because it inspects more plans and now checks subquery tables. A TPM should pilot on the largest representative suite and measure added CI time before making it a required gate across many repositories.
  • Failure modes: The main failure modes are stale baselines after fingerprint changes, unexpected CI failures from new tier 2 subquery findings, and false negatives on DBAL 3 without savepoints. There is also a reporting failure mode: teams expecting per-worker summaries will see nothing in stdout under ParaTest. The release fixes the “unknown” table name bug and improves messaging to name the real table instead of an alias, which reduces triage time when findings do fire.
  • Ramp-up: Moderate. Developers familiar with static analysis and baseline workflows will adopt quickly. Developers unfamiliar with query-plan analysis will need guidance on what query-in-loop, no-possible-index, and tier 2 findings mean, and on when to fix versus baseline. The v1.0.1 noise reduction lowers the ramp-up cost significantly: a tool that previously reported hundreds of low-value findings on a MySQL suite is much easier to introduce as a gate once those false positives are removed.
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin