Created
August 24, 2015 23:08
-
-
Save joseadrian/994802e339be42bc8907 to your computer and use it in GitHub Desktop.
Log queries in console
This file contains hidden or 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 | |
Event::listen('illuminate.query', function($query, $binding, $time, $connections) | |
{ | |
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
foreach ($backtrace as $trace) { | |
if(array_key_exists('file',$trace) && array_key_exists('line',$trace)){ | |
if( strpos($trace['file'],base_path().'/app') !== false ){ | |
PhpConsole\Handler::getInstance()->debug([ | |
$trace['file'] . ':' . $trace['line'] => array( | |
'query' => $query, | |
'binding' => $binding | |
) | |
]); | |
break; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment