This is documentation for Kohana v2.3.x.

Table of Contents
StatusDraft
TodoNeeds to be expanded with examples maybe

Profiler Library

The Profiler adds useful information to the bottom of the current page for debugging and optimization purposes.

How to use

To enable the profiler output on your pages simply load the library:

$this->profiler = new Profiler;

When loaded the profiler will add itself to the system.display event, calling the render() method when the page is being displayed and attaching the output to the bottom of the page.

How to disable

The automatic rendering of the output can be disabled with the following code:

$this->profiler->disable()

This is mostly useful when autoloading the profiler to disable the output for certain pages.

Getting the output

The rendered output may be returned as a string at any time during the page execution by passing TRUE as the first parameter in render():

$output = $this->profiler->render(TRUE)

Note: This will stop any benchmarks currently being run. Only benchmarks and queries that have been run up until this call will be shown in the output.

Configure the profiler

Edit config/profiler.php to configure which items (post, cookie, session, database, benchmarks) the profiler will show.

This change is made to application/config/profiler.php so as to apply only to the specific application.

/**
 * Show everything except database queries. (Other entries are default TRUE, read from system profiler config.
 */
$config['database'] = FALSE;

A complete profiler.php would look like this

<?php defined('SYSPATH') or die('No direct script access.');
 
$config['post'] = FALSE;
$config['cookie'] = FALSE;
$config['session'] = FALSE;
$config['database'] = FALSE;
$config['benchmarks'] = TRUE;

Remember to set at least one of the items to TRUE otherwise the profiler will die in a trace error.

Note: To enable database benchmarking, you will also need to update the following line in your config/database.php file:

'benchmark' => TRUE,