25
24

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 5 years have passed since last update.

Laravel5.0でlaravel-debugbarを使う

Last updated at Posted at 2015-07-23

パッケージインストール

https://github.com/barryvdh/laravel-debugbar
これの2.xを使う。

composer.json
  "require-dev": {
    "barryvdh/laravel-debugbar": "2.*@dev"
  },

⇒ composer update

設定

config/app.phpproviders, aliasesに追記。

app.php
    'providers' => array(
        // ...
        'Barryvdh\Debugbar\ServiceProvider',
    )

    ...

    'aliases' => array(
        // ...
        'Debugbar'  => 'Barryvdh\Debugbar\Facade',
    )

env設定

.env
APP_DEBUG=true

appのURL指定確認

config/app.php
  /*
   |--------------------------------------------------------------------------
   | Application URL
   |--------------------------------------------------------------------------
   |
   | This URL is used by the console to properly generate URLs when using
   | the Artisan command line tool. You should set this to the root of
   | your application so that it is used when running Artisan tasks.
   |
   */

  'url' => '動作環境でのURL',

(ここで別ドメイン等を指定していると_debugbar/assets/配下ファイルが読み込めずデバッグバーが表示されない)

→ここまでで画面下にデバッグバーが表示される。

サンプルコード

実行時間計測

use Debugbar;

// 計測開始
Debugbar::startMeasure('key','ファイルアップロードにかかった時間');

// 測りたい部分

// 計測終了(デバッグバーのTimelineに実行時間が表示される)
Debugbar::stopMeasure('key');

開始と終了で同じ'key'を指定した部分の実行時間が計測される模様。

25
24
2

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
25
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?