May 24, 2012

Symfony - Disable sf_web_debug in your web page

In our development environment, there some way we need to programmaticall disable the Web Debug. In some instance like we are retrieving text data on out controller.
  public function executeGetText(sfWebRequest $request)
  {
     sfConfig::set('sf_web_debug', false); // Here to disable web debug only and hase html response
     // Some code here.. Good luck =)
  }
You can also do this one, this will return you the plain text.
  public function executeGetText(sfWebRequest $request)
  {
     $this->getResponse()->setHttpHeader('Content-type', 'text/plain', true);
     // Some code here.. Good luck =)
  }

No comments: