Weave Code
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

Phpunit Query Count Assertions Laravel Package

mattiasgeniar/phpunit-query-count-assertions

Add PHPUnit/Pest assertions to count and analyze SQL queries in tests. Catch N+1 issues, duplicate queries, slow queries, missing indexes (EXPLAIN), row count problems, and Laravel lazy loading. Supports Laravel 11/12, Doctrine DBAL 4, and Phalcon 6+.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Prioritizes performance testing as a core part of the development lifecycle by enabling automated query budget enforcement in PHPUnit tests, ensuring N+1 issues are caught before deployment.
  • Validates "build vs buy" decisions: adopting this lightweight, MIT-licensed package avoids reinventing custom query-counting logic, saving engineering time and reducing maintenance overhead.
  • Supports roadmap decisions to bake performance constraints into CI/CD pipelines, directly aligning with product goals of maintaining responsive user experiences and minimizing technical debt from database inefficiencies.

When to Consider This Package

  • When your application uses Laravel/Eloquent or other PHP DB layers (PDO/Doctrine-style) and has recurring N+1 query issues in production, or when new features require strict query-count controls (e.g., high-traffic APIs).
  • When your team already uses PHPUnit for testing and needs a frictionless way to assert query counts without complex tooling or custom middleware.
  • Avoid if: your project lacks PHPUnit tests, uses non-PHP database layers (e.g., GraphQL with non-PHP backends), or relies solely on production monitoring tools (e.g., New Relic) without test-time validation needs. Also skip if query performance is already handled by framework-level optimizations (e.g., Laravel’s with() for eager loading) and no regressions have been observed.

How to Pitch It (Stakeholders)

  • Executives: "This tool prevents costly database performance failures before they impact users. By catching N+1 queries in CI during testing, we reduce production incidents, save engineering hours on firefighting, and protect revenue-critical user experiences—all with near-zero setup effort and zero licensing costs."
  • Engineering: "It’s a 5-minute integration into your existing PHPUnit tests: just wrap operations with assertQueryCount() and define query budgets. No custom code, no dependencies—just clear assertions that enforce performance guardrails for critical paths, ensuring regressions are blocked in PRs, not in production."
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport