πQueries
Debugging Database Queries
#Showing queries
You can display all queries that are executed by calling showQueries (or queries).
peek()->showQueries();
// This query will be displayed in peek.
User::firstWhere('email', 'john@example.com'); 
To stop showing queries, call stopShowingQueries.
Alternatively, you can pass a callable to showQueries. Only the queries performed inside that callable will be displayed in Peek. If you include a return type in the callable, the return value will also be returned.
#Counting queries
If you're interested in how many queries a given piece of code executes, and what the runtime of those queries is, you can use countQueries. It expects you to pass a closure in which all the executed queries will be counted.
Similar to showQueries, you can also add a return type to your closure to return the result of the closure.

#Showing slow queries
You can display all queries that took longer than a specified number of milliseconds to execute by calling showSlowQueries.
Alternatively, you can also pass a callable to showSlowQueries. Only the slow queries performed inside that callable will be displayed in Ray.
You can also use the shorthand method, slowQueries() which is the equivalent of calling showSlowQueries:
To stop showing slow queries, call stopShowingSlowQueries.
Last updated