Created
April 12, 2012 15:09
-
-
Save peterjmit/2368005 to your computer and use it in GitHub Desktop.
Profiling Doctrine 2 with Zend Framework
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
# ../application/configs/application.ini | |
resources.doctrine.dbal.connections.default.sqlLoggerClass = "Doctrine\DBAL\Logging\DebugStack" | |
ZFDebug = 1 |
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 | |
// ../application/Bootstrap.php | |
if($this->getOption('ZFDebug') == '1') | |
{ | |
$autoloader = Zend_Loader_Autoloader::getInstance(); | |
$autoloader->registerNamespace('ZFDebug'); | |
$em = $this->bootstrap('doctrine')->getResource('doctrine')->getEntityManager(); | |
$options = array( | |
'plugins' => array( | |
'Variables', | |
'ZFDebug_Controller_Plugin_Debug_Plugin_Doctrine2' => array( | |
'entityManagers' => array($em), | |
), | |
'File' => array('basePath' => APPLICATION_PATH . '/application'), | |
'Exception', | |
'Html', | |
'Memory', | |
'Time', | |
) | |
); | |
$debug = new ZFDebug_Controller_Plugin_Debug($options); | |
$this->bootstrap('frontController'); | |
$frontController = $this->getResource('frontController'); | |
$frontController->registerPlugin($debug); | |
} |
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 | |
// ../application/Bootstrap.php | |
protected function _initZFDebug() | |
{ | |
if(APPLICATION_ENV == 'development') | |
{ | |
$autoloader = Zend_Loader_Autoloader::getInstance(); | |
$autoloader->registerNamespace('ZFDebug'); | |
$em = $this->bootstrap('doctrine')->getResource('doctrine')->getEntityManager(); | |
$em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack()); | |
$options = array( | |
'plugins' => array( | |
'Variables', | |
'ZFDebug_Controller_Plugin_Debug_Plugin_Doctrine2' => array( | |
'entityManagers' => array($em), | |
), | |
'File' => array('basePath' => APPLICATION_PATH . '/application'), | |
'Exception', | |
'Html', | |
'Memory', | |
'Time', | |
) | |
); | |
$debug = new ZFDebug_Controller_Plugin_Debug($options); | |
$this->bootstrap('frontController'); | |
$frontController = $this->getResource('frontController'); | |
$frontController->registerPlugin($debug); | |
} | |
} |
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
# ../application/configs/application.ini | |
resources.doctrine.dbal.connections.default.sqlLoggerClass = "ZendX\Doctrine2\FirebugProfiler" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment