このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
|
basic-library:php-debugbar:1.16 [2020/03/21 10:27] y2sunlight [デバッグ出力 - php-debugbar] |
basic-library:php-debugbar:1.16 [2020/04/18 10:54] (現在) y2sunlight [デバッグ出力 - php-debugbar] |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== デバッグ出力 - php-debugbar ====== | ====== デバッグ出力 - php-debugbar ====== | ||
| - | Version 1.16 | + | Version 1.16 ([[https:// |
| --- // | --- // | ||
| 行 7: | 行 7: | ||
| 関連記事 | 関連記事 | ||
| - | * [[basic-library: | + | * [[basic-library: |
| * [[basic-library: | * [[basic-library: | ||
| * [[basic-library: | * [[basic-library: | ||
| * [[basic-library: | * [[basic-library: | ||
| * [[basic-library: | * [[basic-library: | ||
| - | * [[basic-library: | + | * [[basic-library: |
| - | * [[basic-library: | + | * [[basic-library: |
| + | * [[basic-library: | ||
| + | * [[basic-library: | ||
| * デバッグ出力 - php-debugbar | * デバッグ出力 - php-debugbar | ||
| リンク | リンク | ||
| - | * https:// | + | * https:// |
| - | * http:// | + | * http:// |
| + | テストプログラムの所在 | ||
| + | < | ||
| + | {Project Folder}\test\ | ||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | |||
| + | ===== php-debugbarについて ===== | ||
| + | |||
| + | エラーログと共にデバッグログ(デバッグライト)はプログラム開発では無くてはならない存在です。[[https:// | ||
| + | |||
| + | php-debugbarは、ブラウザにデバッグバーを表示し、PHPでデバッグ出力した情報を画面に綺麗に整形して表示してくれます。Whoops と同様に本当に pretty cool な存在です。whoops と php-debugbar はPHPデバッグ環境の最強バディと言ってもいいでしょう。 | ||
| + | |||
| + | DebugBarには、ブリッジコレクターと呼ばれる他のパッケージとの統合方法が提供されており、ORMの[[https:// | ||
| ===== インストール ===== | ===== インストール ===== | ||
| < | < | ||
| - | D:\>cd usr\workspace3\y2sunlight\apple | + | composer require maximebf/ |
| - | D: | + | |
| </ | </ | ||
| 行 44: | 行 59: | ||
| Generating autoload files | Generating autoload files | ||
| 1 package you are using is looking for funding. | 1 package you are using is looking for funding. | ||
| - | Use the composer fund command to find out more! | + | Use the `composer fund` command to find out more! |
| </ | </ | ||
| + | >Note: | ||
| + | > | ||
| + | |||
| + | パッケージの取得が終わると '' | ||
| + | |||
| + | <code javascript composer.json> | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| ===== テスト ===== | ===== テスト ===== | ||
| + | |||
| + | パッケージのテストフォルダ('' | ||
| <code php / | <code php / | ||
| 行 55: | 行 86: | ||
| use DebugBar\StandardDebugBar; | use DebugBar\StandardDebugBar; | ||
| + | // デバッグモード有効 | ||
| const DEBUG_MODE = true; | const DEBUG_MODE = true; | ||
| + | // 標準のデバッグレンダラー(StandardDebugBar)の作成 | ||
| + | // (DebugBar/ | ||
| $debugbar = new StandardDebugBar(); | $debugbar = new StandardDebugBar(); | ||
| $base_url = ' | $base_url = ' | ||
| $debugbarRenderer = $debugbar-> | $debugbarRenderer = $debugbar-> | ||
| + | // デバッグライトはメッセージコレクターに出力する | ||
| + | // 使い方はvar_dump($var)と同じ | ||
| $arr = [' | $arr = [' | ||
| $debugbar[' | $debugbar[' | ||
| + | // PSR-3 logger互換のログ出力 | ||
| $debugbar[' | $debugbar[' | ||
| + | $debugbar[' | ||
| $debugbar[' | $debugbar[' | ||
| $debugbar[' | $debugbar[' | ||
| 行 70: | 行 108: | ||
| < | < | ||
| < | < | ||
| + | <!-- デバッグモードの場合はJSライブラリを読み込む --> | ||
| <?php if(DEBUG_MODE) echo $debugbarRenderer-> | <?php if(DEBUG_MODE) echo $debugbarRenderer-> | ||
| </ | </ | ||
| < | < | ||
| ... | ... | ||
| + | <!-- デバッグモードの場合は、デバッグバーを表示する --> | ||
| <?php if(DEBUG_MODE) echo $debugbarRenderer-> | <?php if(DEBUG_MODE) echo $debugbarRenderer-> | ||
| </ | </ | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| + | === 実行結果 === | ||
| + | |||
| + | [{{basic-library: | ||
| + | |||
| + | ■ 標準のデバッグレンダラーでは以下の表示ができます | ||
| + | * php ---PHP バージョン番号 | ||
| + | * memory --- メモリ使用量 | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | ■ デバッグ出力の種類毎にフィルタリングできます。 \\ | ||
| + | ■ メッセージをクリックすると変数の展開できます。 | ||
| + | |||
| + | |||