title: Enable debug mode interactively in symfony
body: <p>I'm using symfony 1.4 with Doctrine.</p>
  
  <p>I'm trying to find a way to enable debug mode only if the current <code>sfUser</code> has a special <code>debugger</code> credential.</p>
  
  <p>I already created a filter that deactivates the symfony debug bar if the <code>sfUser</code> has not this credential (the <code>web_debug</code> is set to <code>true</code> in my <code>settings.yml</code> file):</p>
  
  <pre><code>class checkWebDebugFilter extends sfFilter
  {
    public function execute($filterChain)
    {
      if(!$this-&gt;getContext()-&gt;getUser()-&gt;hasCredential('debugger'))
      {
        sfConfig::set('sf_web_debug', false);
      }
  
      $filterChain-&gt;execute();
    }
  }
  </code></pre>
  
  <p>The code of my <code>index.php</code> file is:</p>
  
  <pre><code>require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
  $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false));
  sfContext::createInstance($configuration)-&gt;dispatch();
  </code></pre>
  
  <p>The problem is, as the <code>debug</code> mode is hardcoded to <code>false</code> in my <code>index.php</code>, it is also disabled for debuggers; therefore the Web debug bar does not show Doctrine statements nor timing indications.</p>
  
  <p>Is there a way to enable debug mode only if the current <code>sfUser</code> has a precise credential? </p>
  
  <p>I tried to add <code>sfConfig::set('sf_debug', true);</code> to my <code>checkWebDebugFilter::execute()</code> method but as the filter is executed <em>after</em> Doctrine statements, they are not recorded.</p>
  
  <p>I also tried to add <code>session_start();</code> in my <code>index.php</code> file, then browsing through the <code>$_SESSION</code> variable to check whether the current user has the <code>debugger</code> credential, but it did not work (and it was not in the spirit of symfony either).</p>
  
  <p>Thanks in advance for your answers.</p>