Skip to content

Instantly share code, notes, and snippets.

@umpirsky
Created November 2, 2012 14:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umpirsky/4001744 to your computer and use it in GitHub Desktop.
Save umpirsky/4001744 to your computer and use it in GitHub Desktop.
Enable query logging for Doctrine in Silex
<?php
if ($this['debug']) {
$logger = new DebugStack();
$this->extend('doctrine_orm.configuration', function(Configuration $configuration) use ($logger) {
$configuration->setSQLLogger($logger);
return $configuration;
});
$this->finish(function() use ($self, $logger) {
foreach ($logger->queries as $query) {
$self['monolog']->debug($query['sql'], array('params' => $query['params'], 'types' => $query['types']));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment