Skip to content

Instantly share code, notes, and snippets.

@peterjmit
Created April 12, 2012 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterjmit/2368005 to your computer and use it in GitHub Desktop.
Save peterjmit/2368005 to your computer and use it in GitHub Desktop.
Profiling Doctrine 2 with Zend Framework
# ../application/configs/application.ini
resources.doctrine.dbal.connections.default.sqlLoggerClass = "Doctrine\DBAL\Logging\DebugStack"
ZFDebug = 1
<?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);
}
<?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);
}
}
# ../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