EN | CS | Login | Register

(this page is translated by Google; We're working hard on a human translation)

Firebug

Communications Nette\Debug Firebug and gives developers the ability to send messages to a separate channel, outside the browser window. Error level E_NOTICE and E_WARNING in the Firebug window, then sent automatically. It is also possible to log the exception, although applications caught, but worth it to highlight them. Firebug console is also handy for debugging Ajax applications.

  1. required Firefox version 2 or 3
  2. download extension Firebug
  3. download extension FirePHP (at least version 0.2)
  4. turn on FirePHP in FirePHP menu and activate Firebug Net Panel

Because Nette\Debug with Firebug communicates via HTTP headers, it is necessary to call the logging function even before the PHP script will output anything. You can also enable output buffering and the output delay.

 use Nette\Debug; 

// vypíšeme řetězec do konzoly Firebugu
Debug::fireLog( 'Hello World' );

// ke zprávám je možné přidat indikátor:
Debug::fireLog( 'Info message' , Debug::INFO);
Debug::fireLog( 'Warn message' , Debug::WARN);
Debug::fireLog( 'Error message' , Debug::ERROR);

// do konzoly lze vypsat i pole nebo objekty:
Debug::fireLog( $_SERVER );

The console also supports a special type of table:

 Debug::fireLog( 
array ( '2 SQL queries took 0.06 seconds' , // table title
array (
array ( 'SQL Statement' , 'Time' , 'Result' ), // table header
array ( 'SELECT * FROM Foo' , '0.02' , array ( 'row1' , 'row2' )), // 1. row
array ( 'SELECT * FROM Bar' , '0.04' , array ( 'row1' , 'row2' )) // 2. row
)
), 'TABLE' );

Or you can send an exception in the log:

 try { 
throw new Exception ( 'Test Exception' );
} catch ( Exception $e ) {
Debug::fireLog( $e );
}

The result looks like this:

In addition to the console can issue a variable to the tab "Server" tab under "Net". Here is ready inspector, which can expand or collapse each branch variables. Dumpované each variable must be assigned a unique key (second parameter):

 $arr = array ( 10 , 20 , 
array ( 'key1' => 'val1' , 'key2' => TRUE )
);

Debug::fireDump( $arr , 'My var' );

This browser is as follows:

See also:


Login to submit a comment