9
10

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.

whoopsでエラー画面をリッチにしよう!!

Last updated at Posted at 2016-03-21

Whoopsは開発段階のエラー画面に様々な情報を表示してくれるライブラリです。
メリットは以下3点

  • デバッグに必要な様々な情報を表示することが出来る
  • 様々なフレームワークに対応している
    • CakePHP2、CakePHP3、Laravel等々対応しています
  • 導入が簡単(composerでインストールするだけ)

whoops公式サイト
https://filp.github.io/whoops/

インストール

CakePHP3へインストール

require oldskool/whoops-cakephp:~2.1

# bootstrap.php
Plugin::load('WhoopsCakephp', ['bootstrap' => true]);

CakePHP2へインストール

composer require oldskool/whoops-cakephp:dev-cake2

# bootstrap.php
CakePlugin::load('WhoopsCakephp', array('bootstrap' => true));

whoops単体で使う場合

composer require filp/whoops

CakePHP3で動かしてみる

デフォルト

2016-03-21_23h48_53.png

whoops対応後

2016-03-21_23h49_25.png

※StackTrace、対象部分のコード、変数が全て確認することが出来る

問題点

CakePHPの場合は ErrorHandler を完全に上書きするので ErrorHandler を拡張するライブラリと相性が悪い。。。

9
10
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
9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?