Download the PHP package lucasdotvin/laravel-database-queries-counter without Composer
On this page you can find all versions of the php package lucasdotvin/laravel-database-queries-counter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lucasdotvin/laravel-database-queries-counter
More information about lucasdotvin/laravel-database-queries-counter
Files in lucasdotvin/laravel-database-queries-counter
Package laravel-database-queries-counter
Short Description This package provides a simple trait to check how many queries a test suite has performed.
License MIT
Homepage https://github.com/lucasdotvin/laravel-database-queries-counter
Informations about the package laravel-database-queries-counter
Laravel Database Queries Counter
This package provides a simple way to check how many queries a test suite has performed.
It is important to keep in mind that merely controlling how many queries you perform on the database is not enough to ensure your application has a good performance. This package does not intend to do it, instead, it is thought to help you prevent common mistakes (like N+1 queries).
Installation
You can install the package via composer:
You can publish the traits if you want to extend them:
Usage
Add the CountsQueries
trait to your test suite class to access the package methods, like startCountingQueries
, stopCountingQueries
, and assertDatabaseQueriesCount
, as demonstrated below, where we assert that an index route does not perform N+1 queries to load the posts from a blog:
You can also use the method whileCountingQueries
to avoid having to control when to start and stop counting queries, as below, where we refactor the example above:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Lucas Vinicius
- All Contributors
License
The MIT License (MIT). Please see License File for more information.