Laravel print out sql

01 Mar 2017

In some cases, cannot use debugbar package to profiler SQL. Put it into routes.php. More specific in Laravel 5.4 (/routes/api.php)

\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
    \Illuminate\Support\Facades\Log::info($query->sql);
});

Tweet me @huynhbathanh if you like this post.

Tweet
comments powered by Disqus