Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How integrate Doctrine Queries? #6

Closed
a-h-abid opened this issue May 24, 2015 · 9 comments
Closed

How integrate Doctrine Queries? #6

a-h-abid opened this issue May 24, 2015 · 9 comments

Comments

@a-h-abid
Copy link

Nice thing, just not seeing Db Queries. Can you help how to see Queries through Doctrine? Using doctrine/doctrine-orm-module

@snapshotpl
Copy link
Owner

Try http://phpdebugbar.com/docs/bridge-collectors.html#doctrine
However I will try to simplify this integration.

@bupy7
Copy link
Contributor

bupy7 commented Aug 26, 2016

@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,
        ],
    ],
];

@snapshotpl
Copy link
Owner

@bupy7 great! Can you prepare merge request with this into module?

@bupy7
Copy link
Contributor

bupy7 commented Aug 26, 2016

@snapshotpl Yes, I can. )

@snapshotpl
Copy link
Owner

Awesome. Can you start from #13 ?

@bupy7
Copy link
Contributor

bupy7 commented Aug 26, 2016

@snapshotpl Ok.

@a-h-abid
Copy link
Author

Thanks @bupy7 thats awesome. :)

snapshotpl pushed a commit that referenced this issue Oct 26, 2016
Added doctrine debug collector. #6
@snapshotpl
Copy link
Owner

@a-h-abid merged and released

@a-h-abid
Copy link
Author

a-h-abid commented Feb 8, 2017

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants