MAKING HOOKS IN CODEIGNITER AND RUN BENCHMARK EVERYPAGE!

/* Location: ./application/config/hooks.php */

<?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

/*
| ————————————————————————-
| Hooks
| ————————————————————————-
| This file lets you define “hooks” to extend CI without hacking the core
| files. Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/hooks.html
|
*/

/*
$hook[‘pre_system’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘pre_system_hooks’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);
*/

/*
$hook[‘pre_controller’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘pre_controller_hooks’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);
*/

/*
$hook[‘post_controller_constructor’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘post_controller_constructor’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);
*/

/*
$hook[‘post_controller’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘post_controller’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);
*/

/*
$hook[‘display_override’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘post_controller’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);

$hook[‘cache_override’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘post_controller’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);
*/

$hook[‘post_controller_constructor’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘EnableProfiler’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);

 

/*
$hook[‘post_system’][] = array(
‘class’ => ‘My_Hooks_Classes’,
‘function’ => ‘post_system_hooks’,
‘filename’ => ‘hooks.classes.php’,
‘filepath’ => ‘hooks’,
‘params’ => array()
);
*/

/* End of file hooks.php */
/* Location: ./application/config/hooks.php */

 

LOCATION: /application/hooks/hooks.classes.php

<?php

class My_Hooks_Classes
{

/*
function pre_system_hooks(){

}
*/

/*
function pre_controller_hooks(){

}

*/

/*
function post_controller_constructor(){
}
*/

/*
function post_controller() {
}
/*
/*
function display_override(){
}

*/

/*
function cache_override(){
}

*/
function EnableProfiler()
{
$CI = &get_instance();
$CI->output->enable_profiler(config_item(‘enable_profiling’));
}

/*
function post_system_hooks(){

echo ‘i am post_system_hooks’; die();
}
*/

}

?>

 

put this in /application/config/config.php file:

/*
|————————————————————————–
| enable profiling using hooks.classes.php and hooks.php
|————————————————————————–
|
*/
$config[‘enable_profiling’] = FALSE; //change this to TRUE to enable benchmarking in every page.

 

SOURCE: http://codefury.net/2009/11/enable-site-wide-profiling-with-codeigniter/

Advertisements
This entry was posted in CODE IGNITER. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s