terwey/doctrine-stack-bundle

Symfony DoctrineBundle extension with a Stacktrace per Query

Installs: 68

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

dev-master 2014-05-27 16:04 UTC

This package is not auto-updated.

Last update: 2024-05-11 13:57:29 UTC


README

Symfony DoctrineBundle extension with a Stacktrace per Query

Require in composer.json

"terwey/doctrine-stack-bundle": "dev-master"

Register with your AppKernel

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
			$bundles[] = new Terwey\DoctrineStackBundle\DoctrineStackBundle();
}

WARNING

I currently can't figure out how to get it to properly work from a Bundle so you'll have to replace this file locally: vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php

Change this line:

$this->queries[++$this->currentQuery] = array('sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0);

To this line:

$e = new \Exception;
$shortTrace = explode("\n", $e->getTraceAsString())[5];
$this->queries[++$this->currentQuery] = array('sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0, 'stacktrace' => $e->getTraceAsString(), 'shortstack' => $shortTrace);

If you happen to know how to do this properly, please make a PR!