2
2

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 Debugbarについて

Last updated at Posted at 2023-02-11

Laravel Debugbarとは、デバッグを便利にしてくれるパッケージです。
渡されているパラメータやクエリ文等も確認もできるため便利だったりします。
簡単に導入でき設定もほとんど必要なく、既に実装していたとしても影響を与えるようなこともなく利用できます。

簡単に導入から設定についての説明をまとめてます。

導入

インストールするには以下のコマンドを実行します。

composer require --dev barryvdh/laravel-debugbar

インストール後APP_DEBUGの値がtrueの場合、ページ上に画像のようなものが表示されます。
laravel_debug.png

DEBUGの表示非表示

上記で「APP_DEBUGの値がtrueの場合」と記載しましたが、こちらは「.env」ファイル内に記載されています。
そのためこちらをAPP_DEBUG=falseとすることでDEBUGを非表示にすることができます。

設定

デフォルトでいくつかのタブが表示されていますが、追加で設定することで他の情報も表示させることができます。
設定を変更したい場合は、下記のコマンドを実行し設定ファイルであるconfig/debugbar.phpを生成します。

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

config/debugbar.phpの編集

生成されたconfig/debugbar.php内のcontrollersにて
true/falseを設定することで取得する情報を選択ができます。

config/debugbar.php
 'collectors' => [
    'phpinfo'         => true,  // Php version
    'messages'        => true,  // Messages
    'time'            => true,  // Time Datalogger
    'memory'          => true,  // Memory usage
    'exceptions'      => true,  // Exception displayer
    'log'             => true,  // Logs from Monolog (merged in messages if enabled)
    'db'              => true,  // Show database (PDO) queries and bindings
    'views'           => true,  // Views with  their data
    'route'           => true,  // Current route information
    'auth'            => false, // Display Laravel authentication status
    'gate'            => true,  // Display Laravel Gate checks
    'session'         => true,  // Display session data
    'symfony_request' => true,  // Only one can be enabled..
    'mail'            => true,  // Catch mail messages
    'laravel'         => true,  // Laravel version and environment
    'events'          => true,  // All events fired
    'default_request' => false, // Regular or special Symfony request logger
    'logs'            => false, // Add the latest log messages
    'files'           => false, // Show the included files
    'config'          => false, // Display config settings
    'cache'           => false, // Display cache events
    'models'          => true,  // Display models
    'livewire'        => true,  // Display Livewire (when available)
],

## キャッシュ削除
上記の操作で画面上で反映されない場合は、以下のコマンドを実行することでキャッシュが削除され更新さされるかと思いますので試してください。

php artisan cache:clear
php artisan config:clear
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?