{"id":4605,"date":"2010-07-19T13:21:41","date_gmt":"2010-07-19T04:21:41","guid":{"rendered":"http:\/\/fukata.org\/?p=4605"},"modified":"2017-08-11T22:58:50","modified_gmt":"2017-08-11T22:58:50","slug":"codeigniter-ci_profiler-extends-show-session","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/4605\/","title":{"rendered":"[CodeIgniter]CI_Profiler\u3092\u62e1\u5f35\u3057\u3066CI_Session\u5185\u5bb9\u3082\u51fa\u529b\u3057\u3066\u307f\u305f"},"content":{"rendered":"
Controller\u306a\u3069\u3067\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3068\u30c7\u30d0\u30c3\u30b0\u7528\u306b\u5909\u6570\u306e\u5185\u5bb9\u306a\u3069\u3092\u51fa\u529b\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n
\r\n$this->output->enable_profiler(true);\r\n<\/pre>\n\u30c7\u30d5\u30a9\u30eb\u30c8\u3060\u3068\u3001\u4e0b\u8a18\u306e\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n
\u4eca\u56de\u306f\u7701\u7565\u3057\u307e\u3059\u304c\u3001\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u7528\u306e\u30db\u30c3\u30af\u306a\u3093\u304b\u3092\u4f7f\u3063\u3066\u304a\u304f\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n
\u8ffd\u8a18\uff1a2010-07-20<\/strong> \u76ee\u6b21<\/p> \u3067\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u4e0b\u8a18\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n \u3055\u3089\u306b\u3001hooks.php\u306b\u4e0b\u8a18\u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n \u3053\u308c\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u3084\u3001\u958b\u767a\u74b0\u5883\u3067\u306f\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u3092\u6709\u52b9\u306b\u3057\u3066\u304a\u3044\u3066\u3001\u30c6\u30b9\u30c8\u74b0\u5883\u3084\u672c\u756a\u3067\u4e00\u62ec\u3067\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u306e\u8a2d\u5b9a\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n \u3067\u3001\u672c\u984c\u306ePHP\u6a19\u6e96\u306eSession\u6a5f\u69cb\u3092\u4f7f\u7528\u3059\u308bCI_Session\u62e1\u5f35\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n \u524d\u56de\u306e\u8a18\u4e8b\u3067CI_Session\u306e\u62e1\u5f35\u306b\u3064\u3044\u3066\u66f8\u3044\u305f\u3064\u3044\u3067\u306bCI_Session\u306e\u6301\u3064\u3001\u30e6\u30fc\u30b6\u30c7\u30fc\u30bf\u306e\u5185\u5bb9\u3082\u51fa\u529b\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n
\n\u5927\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u306a\u3044\u3067\u3059\u3051\u3069\u3001\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\nsystem\/application\/hooks\/XC_ProfilerHook.php<\/span><\/h3>\n
\r\n< ?php\r\n\/**\r\n * \u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u7528\u30db\u30c3\u30af\r\n * @author Tatsuya Fukata\r\n *\r\n *\/\r\nclass XC_ProfilerHook {\r\n\t\/** CI\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 *\/\r\n\tprivate $CI;\r\n\t\r\n\t\/**\r\n\t * \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n\t *\/\r\n\tpublic function __construct(){\r\n\t\t$this->CI =& get_instance();\r\n\t}\r\n\t\r\n\tpublic function enable_profiler() {\r\n\t\t$this->CI->output->enable_profiler($this->CI->config->item('hook_enable_profiler'));\r\n\t}\r\n}\r\n\r\n?>\r\n<\/pre>\n
system\/application\/config\/config.php<\/span><\/h3>\n
\r\n\/\/\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u30db\u30c3\u30af\u306e\u6709\u52b9\u5316\r\n$config['hook_enable_profiler'] = true;\r\n<\/pre>\n
system\/application\/config\/hooks.php<\/span><\/h3>\n
\r\n\/\/\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u7528\u30db\u30c3\u30af\r\n$hook['post_controller_constructor'][] = array(\r\n\t'class' => 'XC_ProfilerHook',\r\n\t'function' => 'enable_profiler',\r\n\t'filename' => 'XC_ProfilerHook.php',\r\n\t'filepath' => 'hooks',\r\n);\r\n<\/pre>\n
system\/application\/libraries\/XC_Profiler.php<\/span><\/h3>\n
\r\n< ?php\r\n\/**\r\n * \u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30e9\u7d50\u679c\u306bCI_Session\u306e\u6301\u3064\u3001\u30e6\u30fc\u30b6\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\r\n * \r\n * @author Tatsuya Fukata\r\n *\r\n *\/\r\nclass XC_Profiler extends CI_Profiler {\r\n\tpublic function __construct() {\r\n\t\tparent::__construct();\r\n\t}\r\n\t\r\n\tpublic function run() {\r\n\t\t$output = \"