5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravelのデバック方法

Posted at

Logを使ったデバック方法

//変数の場合
\Log::debug($debug);

//配列やオブジェクトの場合
\Log::debug(print_r($debug, ture));

こうすればLogファイルに出力されます!

useを使うパターンだと、

use Illuminate\Support\Facades\Log;

これをしてあげれば\が先頭にいらなくなります!

SQLのクエリログを確認したい時

\DB::enableQueryLog();\Log::debug(\DB::getQueryLog());を実行前後に挟んであげると確認できます!

$post = new Post;

\DB::enableQueryLog();
$post = $post->where('title', 'Laravel')->get();
\Log::debug(\DB::getQueryLog());

//ddでも出来ます
\DB::enableQueryLog();
$post = $post->where('title', 'Laravel')->get();
dd(\DB::getQueryLog());

デバックする時にはぜひ使ってみてください!

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?