Is there any way in Kohana framework to measure (and display somehow) the analysis of database query execution? In symfony 1.x there was a debug toolbar (see image: http://wiki.netbeans.org/wiki/images/0/0c/Symfony-06e_NB68symfony_es.jpg), in symfony2 there is a profiler tool. I couldn't find anything like this neither in Kohana standard edition nor in web resources.
I'm using particularly kohana 3.2, but I guess it could be very similar in all 3.x versions.
There is a built in Kohana profiler. I always use it like this in my template view:
<?php if (Kohana::$environment !== Kohana::PRODUCTION) : ?>
<div class="footer">
<?php echo View::factory('profiler/stats') ?>
</div>
<?php endif ?>
To show database connections you need to enable profiling in the config/database.php (this is where your DB settings are stored). You can explicitly write TRUE or check the Kohana::$environment variable:
return array
(
'default' => array(
'type' => 'mysql',
'connection' => array(
'dsn' => '',
'username' => 'yyy',
'password' => 'zzz',
'persistent' => FALSE,
),
'identifier' => '',
'table_prefix' => '',
'charset' => 'utf8',
'caching' => Kohana::$environment === Kohana::PRODUCTION,
'profiling' => Kohana::$environment !== Kohana::PRODUCTION,
),
You also need to enable profiling in the bootstrap. This is what I usually do:
if (Arr::get($_SERVER, 'SERVER_NAME') !== 'localhost') // OR your testing URL
{
Kohana::$environment = Kohana::PRODUCTION;
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
$server_name = 'productions_url';
}
else
{
Kohana::$environment = Kohana::DEVELOPMENT;
error_reporting(E_ALL | E_STRICT);
$server_name = 'testing_url';
}
Kohana::init(array(
'base_url' => $server_name,
'index_file' => FALSE,
'charset' => 'utf-8',
'cache_dir' => APPPATH . 'cache',
'errors' => TRUE,
'profile' => Kohana::$environment !== Kohana::PRODUCTION,
'caching' => Kohana::$environment === Kohana::PRODUCTION,
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With