Reputation: 813
I need to check how many sql query is executed in production environment of Symfony2 application.
I tried following in my controller, but it displays me encoded string as result.
<?php
.....
.....
.....
class DefaultController extends Controller
{
/**
* @Route("/")
* @Template()
*/
public function testAction()
{
$profile = $this->container->get('profiler')->loadProfile($token);
$data = $this->container->get('profiler')->export($profile);
print_r($data);
}
}
.....
.....
Upvotes: 2
Views: 1901
Reputation: 29912
Is not recommended to enable profiler in production environment also but...
Into a controller action you could do the following
$profiler = $this->container->get('profiler');
$profile = $profiler->loadProfile($token);
$queries = $profile->getCollector('db')->getQueries();
echo count($queries); //echo is just an example, you could - of course -
//use something like a logger
Upvotes: 2