Created
August 5, 2016 08:36
-
-
Save jsenin/d264fd92fe66b9eca145ae8d0c057b08 to your computer and use it in GitHub Desktop.
improve dd laravel function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* /vendor/laravel/framework/src/Illuminate/Support/helpers.php | |
*/ | |
if (! function_exists('dd')) { | |
/** | |
* Dump the passed variables and end the script. | |
* | |
* @param mixed | |
* @return void | |
*/ | |
function dd($object, $end = true) | |
{ | |
(new Dumper)->dump($object); | |
$callers=debug_backtrace(); | |
foreach($callers as $call) { | |
$line = empty($call['line']) ? false : $call['line']; | |
$file = empty($call['file']) ? false : $call['file']; | |
$class = empty($call['class']) ? false : $call['class']; | |
$function = empty($call['function']) ? false : $call['function']; | |
echo sprintf("\n[%s]: %s %s->%s", $line, $file, $class, $function ); | |
} | |
if ($end) { | |
die(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment