for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ProjetNormandie\CommonBundle\Command;
use Doctrine\DBAL\Logging\DebugStack;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
abstract class DefaultCommand extends ContainerAwareCommand
{
private $sglLoggerEnabled = false;
private $stack = null;
/**
* @param $input
*/
protected function init($input)
if ($input->getOption('debug')) {
$this->sglLoggerEnabled = true;
// Start setup logger
$doctrine = $this->getContainer()->get('doctrine');
$doctrineConnection = $doctrine->getConnection();
$this->stack = new DebugStack();
$doctrineConnection->getConfiguration()->setSQLLogger($this->stack);
// End setup logger
}
* @param $output
protected function end($output)
if ($this->sglLoggerEnabled) {
$output->writeln(sprintf('%s queries', count($this->stack->queries)));