Closed a-h-abid closed 7 years ago
Try http://phpdebugbar.com/docs/bridge-collectors.html#doctrine However I will try to simplify this integration.
@abdmaster,
Create collector:
use Interop\Container\ContainerInterface;
use DebugBar\Bridge\DoctrineCollector;
use Doctrine\DBAL\Logging\DebugStack;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Factory of `DoctrineCollector`.
* @see DoctrineCollector
*/
class DoctrineCollectorFactory implements FactoryInterface
{
/**
* {@inheritdoc}
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$debugStack = new DebugStack;
$entityManager = $container->get('Doctrine\ORM\EntityManager');
$entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
$collector = new DoctrineCollector($debugStack);
return $collector;
}
/**
* {@inheritdoc}
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return $this($serviceLocator, DoctrineCollector::class);
}
}
Update config:
use DebugBar\Bridge\DoctrineCollector;
use <NAMESPACE>\<TO>\DoctrineCollectorFactory;
return [
'php-debug-bar' => [
'collectors' => [
DoctrineCollector::class,
],
],
'service_manager' => [
'factories' => [
DoctrineCollector::class => DoctrineCollectorFactory::class,
],
],
];
@bupy7 great! Can you prepare merge request with this into module?
@snapshotpl Yes, I can. )
Awesome. Can you start from https://github.com/snapshotpl/ZfSnapPhpDebugBar/pull/13 ?
@snapshotpl Ok.
Thanks @bupy7 thats awesome. :)
@a-h-abid merged and released
Awesome :)
Nice thing, just not seeing Db Queries. Can you help how to see Queries through Doctrine? Using doctrine/doctrine-orm-module