Skip to content
Permalink
Browse files

Add dd() as quick alternative for debug(); die(); or step-by-step deb…

…ugging.
  • Loading branch information...
dereuromark committed Jan 6, 2017
1 parent 9eb07d5 commit 6f8baafc75297396d304175198f1a1263b0bc840
Showing with 25 additions and 0 deletions.
  1. +25 −0 src/basics.php
@@ -151,3 +151,28 @@ function breakpoint()
);
}
}
if (!function_exists('dd')) {
/**
* Prints out debug information about given variable and dies.
*
* Only runs if debug level is greater than zero.
* It will otherwise just continue code execution and ignore this function.
*
* @param mixed $var Variable to show debug information for.
* @param bool|null $showHtml If set to true, the method prints the debug data in a browser-friendly way.
* @return void
* @link http://book.cakephp.org/3.0/en/development/debugging.html#basic-debugging
*/
function dd($var, $showHtml = null)
{
if (!Configure::read('debug')) {
return;
}
debug($var, $showHtml, false);
$backtrace = debug_backtrace(false, 1);
pr('dd-location: ' . $backtrace[0]['file'] . ':' . $backtrace[0]['line']);
die(1);
}
}

0 comments on commit 6f8baaf

Please sign in to comment.
You can’t perform that action at this time.