Skip to content

Instantly share code, notes, and snippets.

@vasilake-v
Created September 30, 2019 15:14
Show Gist options
  • Save vasilake-v/a3685ed1e840826b466de7e9d7a96193 to your computer and use it in GitHub Desktop.
Save vasilake-v/a3685ed1e840826b466de7e9d7a96193 to your computer and use it in GitHub Desktop.
Define doctrine sql query logger
<?php
class myController extends Controller
{
public function indexAction()
{
// Start setup logger
$doctrine = $this->getDoctrine();
$doctrineConnection = $doctrine->getConnection();
$stack = new \Doctrine\DBAL\Logging\DebugStack();
$doctrineConnection->getConfiguration()->setSQLLogger($stack);
$em = $doctrine->getManager();
// End setup logger
/**
* Execute here all your queries
* $em->getRepository(...)->find(...)
*/
return $this->render('somebundle:myBundle:index.html.twig',array(
'stack' => $stack
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment