Skip to content

Commit

Permalink
Merge pull request #9989 from cakephp/master-dd
Browse files Browse the repository at this point in the history
Add dd() as quick alternative for debug(); die();
  • Loading branch information
dereuromark committed Jan 7, 2017
2 parents d8be9eb + 9e5f6eb commit d4b1f92
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/basics.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Prints out debug information about given variable and returns the
* variable that was passed.
*
* Only runs if debug level is greater than zero.
* Only runs if debug mode is enabled.
*
* @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.
Expand Down Expand Up @@ -151,3 +151,28 @@ function breakpoint()
);
}
}

if (!function_exists('dd')) {
/**
* Prints out debug information about given variable and dies.
*
* Only runs if debug mode is enabled.
* 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 d4b1f92

Please sign in to comment.