Created
September 30, 2019 15:14
-
-
Save vasilake-v/a3685ed1e840826b466de7e9d7a96193 to your computer and use it in GitHub Desktop.
Define doctrine sql query logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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