Last active
July 1, 2016 19:23
-
-
Save absent1706/59dbd8dad69cd6c933393a7b67e5d728 to your computer and use it in GitHub Desktop.
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 | |
// in app/Providers/AppServiceProvider | |
/*namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{*/ | |
public function boot() | |
{ | |
if (\App::environment('local')) { | |
\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) { | |
$msg = "== SQL: ".$query->sql."\n"; | |
$msg .= "== Params: ".join(', ', $query->bindings)."\n\n"; | |
// if code is executed in CLI, echo message | |
if (\App::runningInConsole()) { | |
echo $msg."\n\n"; | |
} | |
// if code executed by server, log message | |
else { | |
// \Log::debug($msg); | |
error_log($msg); // log into php builtin server | |
} | |
}); | |
} | |
} | |
/* | |
public function register() | |
{ | |
// | |
} | |
}/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment