Friday, 18 October 2013

How to use Nette Debugger in CakePHP


Old CakePHP (version 2) has limited possibilities how to debug code. However, there is a great tool from Nette Framework which enables to debug code in FireFox. You need to install FireBug extension for debugging and FirePHP which enables to log data within HTTP headers.

This debugger outputs debugging data into HTTP headers, not HTML body so you don't mess up your website.

This is how looks Nette Debugger:

This is Nette Debugger HTTP header data in FirePHP





Nette Debugger is great for arrays too



How to enable Nette Debugger in old CakePHP

require_once('Nette/Debug.php');
NDebug::enable(NDebugger::PRODUCTION);
// Uncomment following 3 lins for testing how nette works
// NDebug::fireLog('Hello World'); // render string into Firebug console
// NDebug::fireLog($_SERVER); // or even arrays and objects
// NDebug::fireLog(new Exception('Test Exception')); // or exceptions
// Disable CakePHP error handling, see cake/libs/debugger.php
// Now, Nette will handle also ALL errors from view templates
define('DISABLE_DEFAULT_ERROR_HANDLING', true);
// Turn on errors on view errors (debugging)
// 0 = Production mode. No output.
// 1 = Show errors and warnings.
// 2 = Show errors, warnings, and SQL.
// [SQL log is only shown when you add
$this->element(‘sql_dump’) to your view or layout.]
Configure::write('debug', 2);

 

 







2 comments:

  1. I appreciate your work on Aws. It's such a wonderful read on Aws. Keep sharing stuffs like this. I am also educating people on similar technologies so if you are interested to know more you can watch this:-
    https://www.youtube.com/watch?v=1ek7IdGhbXI

    ReplyDelete
  2. hello!,I really like your writing so a lot! percentage we keep up a correspondence extra about your article on AOL? I require an expert on this area to unravel my problem. Maybe that's you! Taking a look ahead to look you. data science from scratch

    ReplyDelete