LoginSignup
1
4

More than 5 years have passed since last update.

laravel で デバッグを極めようぜ

Last updated at Posted at 2018-10-19

デバッグバーを追加


composer require barryvdh/laravel-debugbar

php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"

何でもいいからとにかく表示せよ

vim .env


APP_DEBUG=true
DEBUGBAR_ENABLED=true

んでからの


php artisan config:cache

大元のコントローラー

自分のIPならデバッグバーを表示。
それ以外ならデバッグバーは表示させぬ。

Controller.php

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function __construct()
    {

//        キャッシュが残るので 毎回 view ファイルを削除する
        $success = \File::cleanDirectory(storage_path()."/framework/views/");

        if(\Request::ip() == "124.222.4224.121"){

            //デバッグモード

        } else {
            \Debugbar::disable();
        }


    }


}



ログを取る

hogecontroller.php
use Log;//一番上でね

Log::debug($data);

/storage/logs/laravel.log
にファイルが出来上がります。

1
4
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
1
4