My team and I are working on a rather big project. There\'s queries going on everywhere - in controllers, in view composers in views (lazy loading) and probably in some othe
You can add this to the Providers/AppServiceProvider.php file and check them in the laravel log file with tail:
tail -f storage/logs/laravel.log
You can even filter with queries you want to log. For example, here I was using Laravel Passport, and didn't want to log all the oauth queries.
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
public function register() {
if (App::environment('local') && env('APP_URL') == 'http://localhost') {
Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
// filter oauth ones
if (!str_contains($query->sql, 'oauth')) {
Log::debug($query->sql . ' - ' . serialize($query->bindings));
}
});
}
}