Skip to content

Easy way to count how many database queries were made in Laravel

Posted by author
1$counter = 0; \DB::listen(function() use (&$counter) {$counter++;});
2 
3// Do stuff
4 
5dd($counter);

Syntax highlighting by Torchlight.dev

End of article