Is there a way for your Laravel application to log output to the standard output of the PHP development server that php artisan serve uses?
In this particular case, I want to output (Eloquent-generated) SQL queries.
I need to be more patient with Google. I found a clue in another question and after some tweaking, I got it to behave just the way I want.
Throw this into app/start/global.php:
DB::listen(function($sql, $bindings, $time)
{
file_put_contents('php://stdout', "[SQL] {$sql} \n" .
" bindings:\t".json_encode($bindings)."\n".
" time:\t{$time} milliseconds\n");
});
And php artisan serve will output SQL queries to the dev server console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With