Created
August 25, 2022 08:07
-
-
Save Grafikart/c82c3d678613374815c5f1fbe1d20fb4 to your computer and use it in GitHub Desktop.
Laravel SQL Log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ajouter ce code dans boot() | |
if ($this->app->isLocal() && ($_SERVER['PHP_SELF'] ?? null) !== 'artisan') { | |
$k = 0; | |
\Illuminate\Support\Facades\DB::listen(function (\Illuminate\Database\Events\QueryExecuted $q) use (&$k) { | |
$k++; | |
file_put_contents('php://stdout', "[{$k}] \e[34m{$q->sql}\t\e[37m]".json_encode($q->bindings)."\t\e[32m{$q->time}ms\e[0m\n"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment