PHPDebugConsole + Error Handler v1.3.1 No more var_dump()

As told via example:

Debug Log

Built In 0.001 sec
PHPDebugConsole is great!
No browser plugin necessary
features/options = Array( [0] => PHP port of the javascript web console api [1] => Log to "console" and/or file [2] => output as html (as seen here), javascript (browser console), or firephp [3] => password protected [4] => errors (even fatal) are captured / logged / displayed [5] => send error notices via email (throttled as to not to send out a flood of emails) [6] => send debug log via email )
example object = It's Magic Example object
properties
private offLimits = I'm a private property
methods
public __toString()
It's Magic
private string foo(string $bar)
Array( [string] => <em>Strings&trade;</em><br /> gets visual whitespace [boolean] => true [int] => 7 [float] => 123.45 [null] => null [timestamp] => 1503530115 [numeric string] => 42 )

Quick Start

Installation Option A:

As of v1.2, PHPDebugConsole is installable via Composer as bdk/debug

composer.json
{
    "require": {
        "bdk/debug": "~1.3",
    }
}

Installation Option B:

Download and extract PHPDebugConsole to your webserver

Download PHPDebugConsole

Usage
<?php
require_once 'path/to/Debug.php';   // PHPDebugConsole is PSR-0/4 compliant
									//   require is unnecessary with an autoloader / composer
$debug = \bdk\Debug\Debug::getInstance(array(
	'collect' => true,
	'output' => true,
));

$debug->log('hello world');

Quality

SensioLabsInsight

PHPDebugConsole abstracts FirePHP. Set the firephpInc config value to FirePHP.class.php's path and PHPDebugConsole does the rest.

  • includes FirePHP.class.php
  • instantiates the firephp class
  • calls firePHP's equivalent methods

PHPDebugConsole will, by default, send output to FirePHP for ajax requests and non text/html output. To specifically use firephp, call $GLOBALS['debug']->set('outputAs','firephp') at any time

FirePHP Examples

These examples require you to have FirePHP installed and enabled

You do not appear to have FirePHP enabled

AJAX

Non text/html output

At a minimum, you must configure either key or both collect and output for the log to be generated/output

Options may be set when instantiating or getting the instance:
$GLOBALS['debug'] = new \bdk\Debug\Debug::getInstance(array(
	'key' => 'Joshua',
	'emailTo' => 'sfalken@wargames.com',
));
and/or via the set() method:
$GLOBALS['debug']->set('key', 'Joshua');
$GLOBALS['debug']->set('emailTo', 'sfalken@wargames.com');
addBR
false convert "\n" to "<br />\n" in strings? <BR> isn't necessary if styling with white-space: pre
collect
false whether the debugger is "on" or not. When false, debug calls are essentially "no-op"

It is not necessary to explicitly set to true if using the key config setting

css
'' supplemental CSS to output
file
null if a valid filepath, log entries to the file. This will supplement the log that is output via output()
filepathCss
"./css/Debug.css" filepath to base CSS. (need not be a publicly accessible)
filepathScript
"./js/Debug.jquery.min.js" filepath to javascript to include. (need not be a publicly accessible)
firephpInc
"./FirePHP.class.php" filepath to firePHP's class include (no other firePHP files are necessary)

PHPDebugConsole does not come bundled with FirePHP - Download it from FirePHP.org

firephpOptions
See FirePHP's documentation
useNativeJsonEncode
true
includeLineNumbers
false
key

null set a "password/key" to enable/view debug info. This key is passed to the page as a request parameter.

Example:
If we set key to "bosco" and visit our page with the debug param (ie http://mysite.com/path/mypage.php?debug=bosco)
collect will be set to true and
output will be set to true

If we don't pass the debug parameter, or pass the incorrect value, collect and output will both be set to false

key takes precedence over collect and output

onOutput
null. set to something callable. Called before log is output.
Callback will receive a single param: $outputAs.
output
false should output() actually output to browser (as html, script, or firephp)?

It is not necessary to explicitly set to true if using the key config setting

outputAs
null, 'html', 'script', or 'firephp'. If null, will be determined automatically
outputCss
true output default/base CSS when outputting log as html?
outputScript
true output the filepathScript along with the log?

The javascript provides the expand/collapse functionality and adds the Font Awesome icons

errorMask
E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR | E_WARNING | E_USER_ERROR | E_RECOVERABLE_ERROR
these errors will appear as "error", remaining errors will appear as "warn"
I am an error
I'm a warning
emailFunc
A callable function that receives 3 parameters: $to, $subject, & $body, Default = "email"
emailLog
false whether to email a debug log.
values may be:
  • false - log not sent
  • 'onError' (or true) - log sent if there was an error masked by the 'errorHandler/emailMask config value
  • 'always' - log always sent
requires 'collect' to also be true
emailTo
$_SERVER['SERVER_ADMIN']
These options deal specifically with debugging objects:

These options are new with v1.3

collectConstants
true whether to collect object constants
collectMethods
true whether to collect object methods, return types, parameter information, etc
objectSort
"visibility" how to sort properties and methods. "visibility", "name", or false|null
objectsExclude
array of classes that will not be recursed into if encountered as a property or array value ["\bdk\Debug\Debug"]
Object will be listed as ("(not inspected)")
outputConstants
true Whether to output object constants
outputMethods
true Whether to output methods for objects
useDebugInfo
true Whether to utilize object's __debugInfo magic method when debuging object

Although __debugInfo is introduced in PHP 5.6, PHPDebugConsole will call the method (if it exists) regardless of PHP version.

if __debugInfo value differs from regular value, the property will be listed with indicator icon. If the value came exclusively from __debugInfo, it will be listed with "debug" visibility
errorHandler

errorHandler options may be set via the Debug class for convenience

onError
null. set to something callable. will also get called on fatal errors.
Callback will receive a single param: array $error
emailMin
15 number of minutes that must elapse before resending an email notice for unique errors
emailMask
E_ERROR | E_PARSE | E_COMPILE_ERROR | E_WARNING | E_USER_ERROR | E_USER_NOTICE
emailThrottledSummary
true Whether to send an email summary of throttled errors on trottle log trash collection
emailTraceMask
E_WARNING | E_USER_ERROR | E_USER_NOTICE
continueToPrevHandler
true PHP only supports one error handler to be defined at a time.
If this is set true, this handler will pass the error off to the previously set handler (chaining).
emailThrottleFile
dirname(__FILE__).'/error_emails.json' - a file used to maintain details of recently emailed errors.

Warning: emailThrottleFile should be set to a path outside the document root or .htaccess should be configured to prevent access / return a 404

Note: In the examples shown below, instantiation of $debug has been omitted for brevity.
assert(expression, mixed[, mixed...])

If first argument evaluates false, log the remaining paramaters

PHP
$debug->assert(1+1==2, 'basic addition');
$debug->assert(1*1==2, 'basic multiplication');
Output

Debug Log

Built In 0.0003 sec
basic multiplication
count([label])

Log the number of times this has been called with the given label.

If label is omitted, count() logs the number of times it has been called at this particular line.

PHP
$debug->count();
$debug->count('myCounter');
for ($i=0; $i<2; $i++) {
	$debug->count();
	$debug->count('myCounter');
}
$debug->count();
$debug->count('myCounter');
Output

Debug Log

Built In 0.0004 sec
count = 1
myCounter = 1
count = 1
myCounter = 2
count = 2
myCounter = 3
count = 1
myCounter = 4
error(mixed[, mixed...])

Log an error message

PHP
$debug->log('the four basic methods', 'log', 'info', 'warn', 'error');
$debug->info('User logged in', false);
$debug->warn('DROP TABLE', 'Students');
$debug->error('No Such Table', 'Students');
Output

Debug Log

Built In 0.0003 sec
the four basic methods, log, info, warn, error
User logged in = false
DROP TABLE = Students
No Such Table = Students
Heads Up: htmlspecialchars() is not applied to the 1st argument.
Good
$debug->error('unsanitized user input', $_GET['whatever']);
Bad
$debug->error($_GET['whatever']);
get(string $what)

Retrieve a configuration value or lastError

PHP
/**
 * It would be sacrilege to use print_r or var_dump to view the return values get() returns
 */
$debug->log('output', $debug->get('output'));
$debug->log('outputAs', $debug->get('outputAs'));
$debug->log('errorHandler/emailMin', $debug->get('errorHandler/emailMin'));
/**
 * PHP's native error_get_last() is only PHP 5 >= 5.2.0
 *    and error_get_last doesn't play nice with set_error_handler
 *    https://bugs.php.net/bug.php?id=60575
 *    use $debug->get('lastError') to get last error
 */
$divByZero =  1/0;
$debug->log('lastError', $debug->get('lastError'));
Output

Debug Log

There was 1 error (warning)

Built In 0.0007 sec
output = true
outputAs = html
errorHandler/emailMin = 15
Warning: /path/to/mypage.inc.php (line 13): Division by zero
lastError = Array( [type] => 2 [category] => warning [typeStr] => Warning [message] => Division by zero [file] => /path/to/mypage.inc.php [line] => 13 [hash] => 49b729d34cade3d9b8bd2809848896c0 [firstOccur] => true [suppressed] => false [stats] => Array( [tsEmailed] => 0 [countSince] => 0 [emailedTo] => ) [vars] => Array( [0] => typically this array contains variables defined at scope of error [1] => ommitted from examples ) [inConsole] => true )
group([mixed...])

Creates a new inline group, indenting all following output by another level.

To close the group, call groupEnd().

PHP
$debug->log("This is the outer level");
$debug->groupCollapsed('Do Stuff');
  $debug->log("Level 2");
  $debug->groupCollapsed('group', 'a', true, null);
    $debug->log("Level 3");
    $debug->warn("Level 3 warning");	// note: error & warn will uncollapse the groups they're in
  $debug->groupEnd();
  $found = isPlaneHere(6.7, 105.62);
  $debug->info('found', $found);
  $debug->log("Back to level 2");
$debug->groupEnd();
$debug->log("Back to the outer level");
/**
 * I usually wrap the inner workings of functions in a group
 * note how additional params will appear formatted as if function args
 */
function isPlaneHere($lat,$lon) {
	$debug = \bdk\Debug\Debug::getInstance();
	$debug->groupCollapsed(__FUNCTION__, $lat, $lon);
	$debug->log('Analyizing the data...');
	$debug->groupEnd();
	return false;
}
Output

Debug Log

Built In 0.0005 sec
This is the outer level
Level 2
Level 3
Level 3 warning
Analyizing the data...
found = false
Back to level 2
Back to the outer level
groupCollapsed([mixed...])

Creates a new inline group. Unlike group() groupCollapse will initially displayed collapsed*

To close the group, call groupEnd().

PHP
$debug->log("This is the outer level");
$debug->groupCollapsed('Do Stuff');
  $debug->log("Level 2");
  $debug->groupCollapsed('group', 'a', true, null);
    $debug->log("Level 3");
    $debug->warn("Level 3 warning");	// note: error & warn will uncollapse the groups they're in
  $debug->groupEnd();
  $found = isPlaneHere(6.7, 105.62);
  $debug->info('found', $found);
  $debug->log("Back to level 2");
$debug->groupEnd();
$debug->log("Back to the outer level");
/**
 * I usually wrap the inner workings of functions in a group
 * note how additional params will appear formatted as if function args
 */
function isPlaneHere($lat,$lon) {
	$debug = \bdk\Debug\Debug::getInstance();
	$debug->groupCollapsed(__FUNCTION__, $lat, $lon);
	$debug->log('Analyizing the data...');
	$debug->groupEnd();
	return false;
}
Output

Debug Log

Built In 0.0005 sec
This is the outer level
Level 2
Level 3
Level 3 warning
Analyizing the data...
found = false
Back to level 2
Back to the outer level
groupCollapsed will start expanded if it contains a nested error or warn, or if groupUncollapse() was used
groupEnd();

Closes the current group

Every call to group() and groupCollapsed() should be paired with groupEnd()

PHP
$debug->log("This is the outer level");
$debug->groupCollapsed('Do Stuff');
  $debug->log("Level 2");
  $debug->groupCollapsed('group', 'a', true, null);
    $debug->log("Level 3");
    $debug->warn("Level 3 warning");	// note: error & warn will uncollapse the groups they're in
  $debug->groupEnd();
  $found = isPlaneHere(6.7, 105.62);
  $debug->info('found', $found);
  $debug->log("Back to level 2");
$debug->groupEnd();
$debug->log("Back to the outer level");
/**
 * I usually wrap the inner workings of functions in a group
 * note how additional params will appear formatted as if function args
 */
function isPlaneHere($lat,$lon) {
	$debug = \bdk\Debug\Debug::getInstance();
	$debug->groupCollapsed(__FUNCTION__, $lat, $lon);
	$debug->log('Analyizing the data...');
	$debug->groupEnd();
	return false;
}
Output

Debug Log

Built In 0.0005 sec
This is the outer level
Level 2
Level 3
Level 3 warning
Analyizing the data...
found = false
Back to level 2
Back to the outer level
groupUncollapse()

sets current group/groupCollapsed to group

Have something important to say? Make sure it's initially visible with groupUncollapse

Note: error(), warn(), and any errors will also uncollapse groups
PHP
$debug->groupCollapsed('Turtle 1');
  $debug->groupCollapsed('Turtle 2');
    $debug->groupCollapsed('Turtle 3');
    $debug->log('Working on this bit of code');
    $debug->log('it\'s inside all of these collapsed groups');
    $debug->log('groupUncollapse() opens things up');
    $debug->groupUncollapse();	// jaws of life to the rescue;
	$debug->info('warn() and error() will also accomplish this');
    $debug->groupEnd();
  $debug->groupEnd();
$debug->groupEnd();
Output

Debug Log

Built In 0.0004 sec
Turtle 1
Turtle 2
Turtle 3
Working on this bit of code
it's inside all of these collapsed groups
groupUncollapse() opens things up
warn() and error() will also accomplish this
info([mixed...])

Informative logging information

PHP
$debug->log('the four basic methods', 'log', 'info', 'warn', 'error');
$debug->info('User logged in', false);
$debug->warn('DROP TABLE', 'Students');
$debug->error('No Such Table', 'Students');
Output

Debug Log

Built In 0.0003 sec
the four basic methods, log, info, warn, error
User logged in = false
DROP TABLE = Students
No Such Table = Students
Heads Up: htmlspecialchars() is not applied to the 1st argument.
Good
$debug->info('unsanitized user input', $_GET['whatever']);
Bad
$debug->info($_GET['whatever']);
log([mixed...])

For general logging information.

PHP
$debug->log('the four basic methods', 'log', 'info', 'warn', 'error');
$debug->info('User logged in', false);
$debug->warn('DROP TABLE', 'Students');
$debug->error('No Such Table', 'Students');
Output

Debug Log

Built In 0.0003 sec
the four basic methods, log, info, warn, error
User logged in = false
DROP TABLE = Students
No Such Table = Students
Heads Up: htmlspecialchars() is not applied to the 1st argument.
Good
$debug->log('unsanitized user input', $_GET['whatever']);
Bad
$debug->log($_GET['whatever']);
PHP
$debug->log('<b>param1</b>');
$debug->log('<b>param1</b>', '<b>param2</b>');	// two params output as param1 = param2
$debug->log('<b>param1</b>', 'param2', 'param3'); // more than two params will be separated by ', '
$debug->log('string', 123, 123.4, '123.4', array('foo'=>'bar'), true, null); // types are styled
$array = array(
	'string' => 'foobar',
	'string_html' => "<span class=\"test\">\r\n\thtmlspecialchar'd &amp; whitespace shown</span>\n",
	'boolTrue'	=> true,
	'boolFalse'	=> false,
	'null'	=> null,
	'int'	=> 123,
	'now'	=> time(),	// hover to see formatted (int/float that's +/- 90 days is assumed to be a timestamp)
	'float'	=> 3.14159265,
	'numeric' => "123",
	'binary' => "\xef\xbb\xbfPesky <abbr title=\"Byte-Order-Mark\">BOM</abbr> and \x07 (a control char).",
);
$debug->log('array', $array);
Output

Debug Log

Built In 0.0004 sec
param1
param1 = <b>param2</b>
param1, param2, param3
string, 123, 123.4, 123.4, Array( [foo] => bar ), true, null
array = Array( [string] => foobar [string_html] => <span class="test"> htmlspecialchar'd &amp; whitespace shown</span> [boolTrue] => true [boolFalse] => false [null] => null [int] => 123 [now] => 1503530115 [float] => 3.14159265 [numeric] => 123 [binary] => \xef\xbb\xbfPesky <abbr title="Byte-Order-Mark">BOM</abbr> and \x07 (a control char). )
output()

"conditionally" output (or return) collected log

As of v1.2, explicitly calling output() is no longer necessary.. log will be output automatically at end of script

Log will only be output if either of the following conditions are met

  • output option set to true (default: false)
  • key option set (default: null) and key passed to page as request param
PHP
// initialize PHPDebugConsole
require '/path/to/Debug.php'; // or via autoloader
$debug = \bdk\Debug\Debug::getInstance(array(
	'collect' => true,	// turn logging on
	'output' => true,	// if left false (default), the output() method will return an empty string
));
$debug->log('hello world');
echo $debug->output();
Output

Debug Log

Built In 0.0006 sec
hello world
set(mixed[, mixed])

Set one or more configuration options

Returns previous value

PHP
$debug->set('collect', true);
$debug->set('output', true);
$debug->set('errorHandler/emailMask', E_ERROR);	// only email error notice for E_ERROR
// or set multiple values via an array.. values not passed will remain as their current value*
$debug->set(array(
	'collect' => 'true',
	'output' => 'true',
	'errorHandler' => array(
		'emailMask' => E_ERROR,
	),
));
setErrorCaller([array])

Set the calling/originating source file & line for next error

Example: you deprecate a function and trigger a E_USER_DEPRECATED error within the function. Rather than reporting that an error occurred on the file/line of trigger_error(), you can use setErrorCaller() to report the error occurring from the file/line that called the function.

This is is the file/line that will be written to server's error log

This override will apply until cleared, error occurs, or groupEnd()

PHP
trustyOldFunction();
$debug->log('lastError', $debug->get('lastError'));
function trustyOldFunction() {
	\bdk\Debug\Debug::getInstance()->setErrorCaller();
	trigger_error('trustyOldFunction\'s days are numbered.  Use superNewFunction instead.', E_USER_DEPRECATED);
}
Output

Debug Log

There was 1 error (deprecated)

Built In 0.0005 sec
User Deprecated: /path/to/mypage.inc.php (line 1): trustyOldFunction's days are numbered. Use superNewFunction instead.
lastError = Array( [type] => 16384 [category] => deprecated [typeStr] => User Deprecated [message] => trustyOldFunction's days are numbered. Use superNewFunction instead. [file] => /path/to/mypage.inc.php [line] => 1 [hash] => ddc08fdc68ae3302d7b07e78c4ca7066 [firstOccur] => true [suppressed] => false [stats] => Array( [tsEmailed] => 0 [countSince] => 0 [emailedTo] => ) [vars] => Array( [0] => typically this array contains variables defined at scope of error [1] => ommitted from examples ) [inConsole] => true )
PHP
$list = array(
	// note different order of keys / not all rows have all cols
	array('name'=>'Bob', 'age'=>'12', 'sex'=>'M', 'Naughty'=>false),
	array('Naughty'=>true, 'name'=>'Sally', 'extracol' => 'yes', 'sex'=>'F', 'age'=>'10'),
);
$debug->table('list', $list);
$debug->log('list', $list);
Output

Debug Log

Built In 0.0004 sec
list
 nameagesexNaughtyextracol
0Bob12Mfalse
1Sally10Ftrueyes
list = Array( [0] => Array( [name] => Bob [age] => 12 [sex] => M [Naughty] => false ) [1] => Array( [Naughty] => true [name] => Sally [extracol] => yes [sex] => F [age] => 10 ) )
time([string $label])

Start a timer identified by label

  • This method does not write to the console
  • If no label specified, a timer is added to a timer stack
  • If timer with passed label already started, this will not reset it
PHP
$debug->time('timer a');
usleep(100);
$debug->time();		// stack: 0
usleep(100);
$debug->time();		// stack: 1
usleep(100);
$debug->timeEnd();	// stack: 1
usleep(100);
$debug->timeEnd('timer a');	// pauses "timer a" and outputs the running time (does not "end" timer)
usleep(100);
$debug->timeEnd();	// stack: 0
$debug->timeEnd('timer a');
Output

Debug Log

Built In 0.0018 sec
time: 0.0002 sec
timer a: 0.0011 sec
time: 0.0009 sec
timer a: 0.0011 sec
timeEnd([string label][, bool $return = false])

Log time elapsed since started with time()

  • If label is passed, the timer is paused. Additional calls to timeEnd('label') will return the same value until unpaused with time('label')
  • If no label is passed, timer is removed from a timer stack and logged
  • $return: if true, the time will be returned as a float (in seconds) and will not be logged
PHP
$debug->time('timer a');
usleep(100);
$debug->time();		// stack: 0
usleep(100);
$debug->time();		// stack: 1
usleep(100);
$debug->timeEnd();	// stack: 1
usleep(100);
$debug->timeEnd('timer a');	// pauses "timer a" and outputs the running time (does not "end" timer)
usleep(100);
$debug->timeEnd();	// stack: 0
$debug->timeEnd('timer a');
Output

Debug Log

Built In 0.0018 sec
time: 0.0002 sec
timer a: 0.0011 sec
time: 0.0009 sec
timer a: 0.0011 sec
timeGet([string $label][, bool $return = false][, integer $precision = 4])

Get the running time without stopping/pausing the timer

    This method does not have a web console API equivalent.
    This example shows how to "collect" the time spent inside a function
    queryDb('INSERT INTO student (id, name, age) VALUES ("1", "alan", 28)');
    // other stuff
    queryDb('SELECT * FROM student ORDER BY age');
    // other stuff etc
    $debug->timeEnd('query db');	// total time spent querying
    
    function queryDb($query) {
    	$debug = \bdk\Debug\Debug::getInstance();
    	$debug->groupCollapsed(__FUNCTION__, $query);
    	$debug->time('query db');			// start / un-pause
    	// query code omitted
    	$debug->timeEnd('query db', true);	// pause: passing 2nd param so this is "silent"
    	$debug->groupEnd();
    	return $results;
    }
    Output

    Debug Log

    Built In 0.0014 sec
    query db: 0.0005 sec
warn(mixed[, mixed])

Log a warning

PHP
$debug->log('the four basic methods', 'log', 'info', 'warn', 'error');
$debug->info('User logged in', false);
$debug->warn('DROP TABLE', 'Students');
$debug->error('No Such Table', 'Students');
Output

Debug Log

Built In 0.0003 sec
the four basic methods, log, info, warn, error
User logged in = false
DROP TABLE = Students
No Such Table = Students
Heads Up: htmlspecialchars() is not applied to the 1st argument.
Good
$debug->warn('unsanitized user input', $_GET['whatever']);
Bad
$debug->warn($_GET['whatever']);

v1.3.1 2015-05-05

  • Bug fix: nested arrays weren't being output via the table() method
  • HTML output now has a checkbox to toggle passing the debug param via cookie
  • Bug fix: setErrorCaller may fail to resolve calling file/line if call_user_func was in the stack trace
  • emailThrottledSummary : new option to disable email summary of throttled errors
    Scenario:
    1. error a occurs… which fires off an error alert email. The error continues to occur but the error is emailed no more than once every emailMin minutes.
    2. error b occurs… which fires off an error alert email. "Trash Collection" is performed on the throttle log. If there is a record of error a (or any other error) having occured more than emailMin minutes ago (and which did not trigger an email notice), a summary of these errors will be emailed

v1.3 2015-04-01

  • objectExclude option - specify classNames to exclude from inspecting if found nested in array or object properties
  • objectSort option - sort object's properties, methods, & constants by 'name', 'visibility', or unsorted

v1.3b2 2015-03-17

  • Fix bug #13. Affected debugging objects with properties that weren't declared in the class - PHP bug #69249
  • Object constants are now output
  • Object's __debugInfo method now used if defined
  • Collapsed groups get an indicator if they contain an error or warning
  • New config options useDebugInfo, collectConstants, outputConstants

v1.3b 2015-02-27

  • Much more detailed output for objects.
    Uses PHP's reflection class - which in turn may read PHPDoc comments - to provide details such as method parameters, return type, visibility, and descriptions.
  • New config settings:
    • emailfunc (default value = "mail")
      Accepts a callable that receivies to, subject, and body. Email's generated by the debugger are passed to this function.
    • collectMethods (default value = true)
    • outputMethods (default value = true)
  • New outputAs option: "script"
    Generates <script> with console calls
  • CSS: Added "m_" prefix to method classnames (.log, .info, .error, .warn, etc)
  • Removed deprecated method setCfg()
  • Removed Utilities::isRecursive()
  • Renamed & shuffled many internal / protected methods

v1.2 2014-12-03

  • Installable via Composer as bdk/Debug
  • Explicitly calling output() is no longer necessary
  • Breaking change Param passed to onError function changed from boolean to array
      New Param
      array $error - an array containing all sorts of useful error details.
      If the error is fatal, $error['category'] will be "fatal"
      This is the same array returned by get('lastError')
      Previous
      boolean $isFatal
  • if emailLog is set to "onError", an error matching the ErrorHandler/emailMask mask option must have occured for email to be sent. Previously, any error (incl deprecated) would have qualified.
  • moved errorMask option from ErrorHandler to Debug
  • ErrorHandler class (introduced in v1.1) is now a stand-alone class (no dependencies) and can used completely independently of the debug class.

    Documentation coming soon, but a few core ErrorHandler methods include:

    • getInstance - get the instance of ErrorHandler
    • get and set - get and set config values
    • register & unregister - register/unregister the error handler
    • registerOnErrorFunction($callable) - register an onError "callback"
      • onError function gets passed a single param - array $error
      • Multiple callbacks may be registered
      • Yes, even fatal errors!
    • unregisterOnErrorFunction($callable) - unregister an onError function
    • setErrorCaller - Debug's setErrorCaller() simply calls this
  • Ton of internal reorganization

v1.1 2014-10-10

  • Dropped PHP4 support
  • Now namespaced namespace bdk\Debug;
  • Internal: now follows PSR-2 coding standard
  • Internal: error-handling methods and functionality now in separate classes
  • Internal: base css moved to Debug.css
  • cfg and data properties are now protected
  • added singleton getInstance method - which is the preferred way to instantiate the class: $debug = \bdk\Debug\Debug::getInstance();
  • the javascript is now output with the log (by default) - no need to output/include separately
  • New config options
    • firephpOptions (array)
    • outputScript (boolean) true
    • filepathCss (string) "./Debug.css"
    • filepathScript (string) "./Debug.jquery.min.js"
  • deprecated setCfg(). Use set() (which semantically matches "get()")
  • FirePHP options are now configurable
  • FirePHP's default path changed from ./FirePHP/FirePHP.class.php to ./FirePHP.class.php
Candy Bars Now
Geocache

I Last Twittled:

  • Just released http://t.co/vH5MV7Epzy into the wild. Be free my helpful tool... June 16th, 2014
  • 23 new wrappers added to the collection this weekend - http://t.co/aHED0MgjmA June 2nd, 2013
  • What's the world record for accelerating from 0 to Mach 1? #stratos October 14th, 2012
  • Finally posted 6 new wrappers to the collection http://t.co/OKhoeQOv August 5th, 2012
  • Just added 18 wrappers to the wrapper collection - http://t.co/Fljpm7f6 February 29th, 2012
Fork me on GitHub