Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel show debug query sql

// Debug SQL query
// app/Providers/AppServiceProvider.php
public function boot()
{
    //...

    $this->debugQueries();
}
protected function debugQueries()
{
    if (env('APP_DEBUG_QUERIES')) {
        DB::listen(function ($query) {
            error_log(
                "Query [$query->time ms]: $query->sql
"
                . "Params: " . print_r($query->bindings, true)
            );
        });
    }
}
 
PREVIOUS NEXT
Tagged: #laravel #show #debug #query #sql
ADD COMMENT
Topic
Name
9+1 =