日本語 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)

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.
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">
  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'

    $('#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 () {
     this.orgImage = $(this).attr('src');
     this.rolloverImage = this.orgImage.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
// -->
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'] = '';
//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>.
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"))

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.

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