Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Last active October 19, 2021 05:48
Show Gist options
  • Save Ocramius/c1513eb0472be921613d to your computer and use it in GitHub Desktop.
Save Ocramius/c1513eb0472be921613d to your computer and use it in GitHub Desktop.
SQL Logger in Doctrine 2 ORM and ZF2
<?php
use Zend\ServiceManager\ServiceLocatorInterface;
return [
'service_manager' => [
'delegator' => [
'doctrine.entitymanager.orm_default' => [
function (ServiceLocatorInterface $sl, $name, $requestedName, $callback) {
/* @var $em \Doctrine\ORM\EntityManager */
$em = $callback();
$em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
return $em;
},
],
],
],
];
@douglasforseti
Copy link

I had to change from delegator to delegators to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment