Skip to content

Instantly share code, notes, and snippets.

@chimit
Created May 25, 2023 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chimit/aeb9019984659d472b319fd886c121cd to your computer and use it in GitHub Desktop.
Save chimit/aeb9019984659d472b319fd886c121cd to your computer and use it in GitHub Desktop.
Output all SQL queries in Laravel
<?php
// Debug SQL queries
// Put anywhere, e.g. in routes/api.php
if (config('app.debug')) {
\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
echo 'Query: '.$query->sql."\n\n";
echo 'Bindings: '.var_export($query->bindings, true)."\n\n";
echo 'Time: '.$query->time."\n\n";
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment