Frameworks, PHP, Programming

Customize the Symfony Web Debug Toolbar

Fabien Potencier wrote:

The Symfony Web debug toolbar is one of the developer best friend. It is always conveniently accessible in the browser when using the development environment. It gives you everything you need to know about the current page and ease the debugging of your applications. Until now, the information in this toolbar was hardcoded. But as of Symfony 1.2, the Web debug toolbar is entirely configurable. The new toolbar is composed of panels. Each panel is composed of a title and an optional panel content, and the panel is represented by a PHP object.

sfWebDebugPanelAssets class

class sfWebDebugPanelAssets extends sfWebDebugPanel
{
  public function getTitle()
  {
    return 'assets';
  }

  public function getPanelTitle()
  {
    return 'Stylesheet and JavaScript files from sfWebResponse';
  }

  public function getPanelContent()
  {
    return null;
  }
}

frontendConfiguration class

class frontendConfiguration extends sfApplicationConfiguration
{
  public function configure()
  {
    $this->dispatcher->connect('debug.web.load_panels', array($this, 'configureWebDebugToolbar'));
  }

  public function configureWebDebugToolbar(sfEvent $event)
  {
    $webDebugToolbar = $event->getSubject();
    $assetsPanel = new sfWebDebugPanelAssets($webDebugToolbar);
    $webDebugToolbar->setPanel('assets', $assetsPanel);
  }
}

Links

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s