Class Options
The following example passes options to the class on load:
$debug_options=array
(
'url_key' => 'debug',
'url_pass' => 'true',
'replace_error_handler' => true,
'check_referer' => false,
'die_on_error' => true,
'debug_console' => false,
'allowed_ips' => null,
'session_start' => false,
'show_interface' => true
);
url_key
To show the interface we use a "$_GET" paramater in the url, the default key is "debug" and should be changed to something else!
Default value: debug (string)
url_pass
This is the value to pass in the url, the default value is "true" and should be changed to something else.See url_key.
Default value: true (string)
replace_error_handler
Set this options to true to replace the default php error handler and php will send errors to the debug panel.It is recommended to leave it set to true.
Default value: true (bool)
check_referer
This option,if set to true,will check for the key and pass with the referer if any.This is quite usefull to debug ajax scripts with the show_interface option set to "false",and the debug_console set to "true".For more information on this setup see Ajax Debugging(Chrome only)
Default value: false (bool)
die_on_error
Set this option to false to continue if fatal error occurs,keep in mind that this will only work with replace_error_handler set to "true"
Default value: true (bool)
debug_console
Only for Chrome,with phpConsole class installed.This feature is usefull to to debug ajax scripts.For more information and detailed usage,see Ajax Debugging(Chrome only)
Default value: false (bool)
allowed_ips
To restrict access use this option to pass an ip or an array of ip's,and only the allowed ip's will be able to turn on/off the debug interface.IT is advised to use this option under production environment.
Default value: null (string|array)
session_start
For persistent debugging,set this option to true,and the class will try to store the key and pass in $_SESSION var.You will need to use "url_key"+Off to hide the interface.While this is a good option to navigate an application,it will not work if the class is not initialized at very start of the application. see session_start() function for more information.
Default value: false (bool)
show_interface
This option, if set to "true",does not show the floating panel. It is usefull to send messages to console only. See debug_console and Ajax Debugging(Chrome only)
Default value: true (bool)
Typical Setup Examples
Setup For Development
This example,demostrates how to configure and load the interface under testing environment:
require_once('PtcDebug.php');
$_GET['debug']=true; # turn on the debug
//$_GET['debugOff']=true; # turn off debug
$debug_options=array
(
'session_start' => true,
);
Production Environment
This example,demostrates how to configure and load the interface under production environment:
require_once('PtcDebug.php');
# replace php built in error handler and continue execution if fatal error occurs
$debug_options=array
(
'url_key' => 'someKey',
'url_pass' => 'somePass',# use a complicated string!
'replace_error_handler' => false, # has been replaced already
'allowed_ips' => array(1.2.3.4,2.3.4.5),
'show_interface' => true
);
Ajax Debugging(Chrome only)
This example,demostrates how to configure and show the buffer messages in the Chrome browser console.Particularly usefull to debug ajax
scripts. Keep in mind that this setup needs phpConsole class and the Chorome extension installed to work. Make sure you have downloaded the phpConsole class from the repository, and install the Chrome browser extension before starting to use this class to send messages to the console.
require_once('PtcDebug.php');
$debug_options=array
(
'replace_error_handler' => true,
'die_on_error' => false,
'debug_console' => true,
'check_referer' => true, # check if referer has key and pass.
'show_interface' => false # don't show interface, only console
);