Skip to content

Instantly share code, notes, and snippets.

@cleaver
Last active November 16, 2015 16:19
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 cleaver/6ba2092950ee7ba95dc1 to your computer and use it in GitHub Desktop.
Save cleaver/6ba2092950ee7ba95dc1 to your computer and use it in GitHub Desktop.
Laravel: debug SQL statements
<?php
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
Event::listen("illuminate.query", function($query, $bindings, $time, $name){
$this->output($query);
$this->output(json_encode($bindings));
// Or, send to log:
Log::sql($query."\n");
Log::sql(json_encode($bindings)."\n");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment