NEKOGET Report

日本語 english

-

Goodby var_dump! Welcome Profiler of CodeIgniter!!!

Codeigniter  Profiler
Hi! PHP User.
Do you use 'var_dump' ?
I use it very frequently.
var_dump! var_dump! var_dump!!!

However, I did not use it very much.
(I use it a little)

Why?
I have begun to use CodeIgniter.
There is a very convenient library in CodeIgniter.
It is profiler.

This image is profiler of CodeIgniter. This image extracted it.
(This system use language file is Japanese.Therefore the text in the image is written in Japanese.)
I wanted to make it easy to use this library more.And I challenged it.
http://d.hatena.ne.jp/localdisk/20110521/1305964812
I referred to this BLOG.


(1) I make view file.
file path : /application/views/profiler.php
jquery is necessary for this javascript code.
<script type="text/javascript">
//<!--
$(function(){
  if ($('#codeigniter_profiler').length > 0) {
    var prof = $('<div>', {
      id: 'profiler',
      html: $('<img>', {
      id : 'profiler_button',
      height: 35,
      width: 178,
      alt: 'Toggle Profiler',
      title: 'Toggle Profiler',
      src: '<?php echo base_url(); ?>common/images/profiler/nav_toggle_darker.png'
     })
    });

    $('body').prepend(prof);
    $('body').prepend($('#codeigniter_profiler'));
    $('#profiler').css('text-align', 'right');
    $('#profiler').css('border-top', '10px #000 solid');
    $('#codeigniter_profiler').css('display', 'none');
    $('#codeigniter_profiler').css('background', '#FFF');
    $('#codeigniter_profiler').click(function () {
     $('#codeigniter_profiler').slideToggle();
    });
    $('#profiler_button').hover(function(){
     this.orgImage = $(this).attr('src');
     this.rolloverImage = this.orgImage.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
     $(this).attr('src',this.rolloverImage);
    },function(){
     $(this).attr('src',this.orgImage);
    });
  }
});
// -->
</script>
I use 'Modular Extensions - HMVC'. Therefore I install common parts in application/views/.
You should change it in a more plain file name when If you do not use it.


(2) I added a postscript in config.php
file path : application/config/config.php
When $config['genuine_url'] and $config['base_url'] are equal to it, the application are installed in the operative server.
The application is installed in the server for development when they are not equal to it.
//operative server URL
$config['genuine_url'] = 'http://press.nekoget.com/';
//This server URL
$config['base_url'] = 'http://localhost/nekoget_report/trunk/';


(3) I added this code on A view file. It place in <head></head>.
<?php
if($this->config->item("genuine_url") !=  $this->config->item("base_url"))
{
 echo $this->load->view("profiler" , '' , TRUE);
}
?>


(4) I wrote it on Controller file.
if($this->config->item("genuine_url") != $this->config->item("base_url"))
{
 $this->output->enable_profiler();
}



My Impression
Profiler result on page top.I feel that it is a good position.

It does not interfere with the work.
when I click on <div id="codeigniter_profiler">. Profiler result is chenge to hidden.
The security that a displayed accident is hard to produce. And it is very convenient.

profiler
Next challenge it
・I expand CI_Profiler Class (I create MY_Profiler.php)


As I write "$this->output->enable_profiler();", I want to do it.
When "$config['genuine_url']" is unestablished or when application is installed in the operative serve , It is necessary not to see it.



Special thanks
http://d.hatena.ne.jp/localdisk/20110521/1305964812
@localdisk
I thank him AND this good idea.


Do not you try this idea, too?
Let's Enjoy!

Creation data : 2011-05-23 19:48

Last update : 2011-05-23 19:48

-

-