Log database queries in Laravel

  • Language:: PHP
  • Type:: Back-end
  • Context:: Log db queries in Laravel
  • Description – a text-based description of the snippet
  • Snippet –
use Illuminate\Support\Facades\DB;
 
 
public function UserController()
{
 
    DB::enableQueryLog();
    $arr_user = DB::table('users')->select('name', 'email as user_email')->get();
    dd(DB::getQueryLog());
}

📇Additional Metadata

  • 📁Type:: snippet
  • 🏷️Tags:: Laravel, PHP
  • 📡Status:: #status/🌲