tjtjtjのメモ

自分のためのメモです

Yii Debug Toolbar

yiidebugtbというエクステンションを使ってみる。CakePHP DebugKitみたいなものか。

インストール

  1. yiidebugtbとかyiidebugtb - yii extensionsとかから持ってくる。
  2. 解凍し、/webroot/protected/extention 下にコピー。
  3. /webroot/protected/config/main.php を上記リンク先の例のように変更する
<?php
//...略...
	// autoloading model and component classes
		'import'=>array(
		'application.models.*',
		'application.components.*',
//↓↓↓ここ↓↓↓
		'application.extensions.yiidebugtb.*',
//↑↑↑ここ↑↑↑
	),
//...略...
	'components'=>array(
//...略...
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
//...略...
//↓↓↓ここ↓↓↓
				array( // configuration for the toolbar
					'class'=>'XWebDebugRouter',
					'config'=>'alignLeft, opaque, runInDebug, fixedPos, collapsed, yamlStyle',
					'levels'=>'error, warning, trace, profile, info',
					'allowedIPs'=>array('127.0.0.1','::1'),
				),
//↑↑↑ここ↑↑↑
//...略...
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),
//...略...

確認

webページの左上に「Yii」と表示されるので、クリックするとイロイロ見ることができる。残念ながら「Database Queries」で各クエリが何msかかったのかわからない。
f:id:tjtjtjofthedead:20110318001020j:image

というか

というか、上記 /webroot/protected/config/main.php の変更例でコメントアウトされている「CWebLogRoute」の見せ方を変えているってわけだ。各クエリのプロファイルをここに載せるにはframeworkに手を入れないとダメかもなあ。

この辺が参考になりそう。
ロギング - Yii guide
Profiling SQL Executions - Yii guide
fdbweblogroute - Yii extensions