Laravel 4 SQL log / console

后端 未结 8 2138
感动是毒
感动是毒 2020-12-31 05:50

Is there something similar in Laravel that allows you to see the actual SQL being executed? In Rails, for example, you can see the SQL in console. In Django you have a tool

相关标签:
8条回答
  • 2020-12-31 06:19

    I do this in Laravel 4.

    Just set it once in app/start/global.php or anywhere but make sure it is loaded and then it will start logging all your SQL queries.

    Event::listen("illuminate.query", function($query, $bindings, $time, $name){
        \Log::sql($query."\n");
        \Log::sql(json_encode($bindings)."\n");
    });
    
    0 讨论(0)
  • 2020-12-31 06:20

    There is a Composer package for that: https://packagist.org/packages/loic-sharma/profiler

    It will give you a toolbar at the bottom with SQL queries, log messages, etc. Make sure you set debug to true in your configuration.

    0 讨论(0)
提交回复
热议问题