LoginSignup
0
0

デバッグのやり方

Last updated at Posted at 2024-04-26

デバックのやり方

  1. ログに出す
  2. 画面に出力する
  3. コンソールに出す
  4. Symfonyのツールバーを使う

1. ログに出す

$startDateTime = new \DateTime();

log_info('$startDateTime',[$startDateTime]);
// $startDateTime ["2024-04-16T06:30:00+09:00"]

→Entity等のオブジェクトは出力できない(省略して表示される)ので注意

2. 画面に出力する

var_dump();
→Entity系を出力するとリレーション系も大量に出力されるので要注意

dd(); / dump(); die();
※ ddはdump and dieの意

3. コンソールに出す

js系のログはconsole.log(文字列);を使用する

$.ajax({
        url: '{{ url('recommend', {'type': 1}) }}',
        type: 'GET',
    }).done(function(data) {
        console.log('Success');
        // 成功した時の処理
    }).fail(function() {
        console.log('Failed');
    });

コンソールの確認方法

Google Chromeの検証ツールを使用
※ 右クリックで「検証」選択 or F12押下

4. Symfonyのツールバーを使う

以下の設定が必要

.env
APP_ENV=dev
APP_DEBUG=1

⇒devよりprodのほうが早い

※ 表示されない場合:app/config/eccube/packages/dev/に以下を配置

web_profiler.yaml
web_profiler:
    toolbar: true
    intercept_redirects: false

framework:
    profiler: { only_exceptions: false }
0
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
0
0