Skip to content

Instantly share code, notes, and snippets.

@fsalehpour
Last active December 25, 2015 08:29
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 fsalehpour/6947119 to your computer and use it in GitHub Desktop.
Save fsalehpour/6947119 to your computer and use it in GitHub Desktop.
SQL query logging for Laravel 4. Put it somewhere to run, like app/filters.php. Thanks to Shawn McCool
<?php
// Logs SQL queries as info
// Thanks to @ShawnMcCool
// Link to the original content by Shawn McCool:
// https://github.com/LaravelIO/laravel-io/blob/master/app/filters.php#L71
Event::listen('illuminate.query', function($sql, $bindings)
{
foreach ($bindings as $val) {
$sql = preg_replace('/\?/', "'{$val}'", $sql, 1);
}
Log::info($sql);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment