Created
April 29, 2015 17:44
-
-
Save unstoppablecarl/ac28abe60d9686e6a8f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
use Illuminate\Support\Debug\HtmlDumper; | |
use Symfony\Component\VarDumper\Dumper\CliDumper; | |
use Symfony\Component\VarDumper\Cloner\VarCloner; | |
if(!function_exists('d')) { | |
/** | |
* Dump the passed variables in place on page. Primarily for views. | |
* @param mixed | |
* @return void | |
*/ | |
function d() { | |
$cloner = new VarCloner; | |
$dumper = new HtmlDumper(); | |
foreach(func_get_args() as $x){ | |
$clone = $cloner->cloneVar($x); | |
// echo by default | |
$dumper->dump($clone); | |
} | |
} | |
} | |
if(!function_exists('dl')) { | |
/** | |
* Dump the passed variables to the log. | |
* @param mixed | |
* @return void | |
*/ | |
function dl() { | |
$cloner = new VarCloner; | |
$dumper = new CliDumper; | |
$logLineWriter = function($line, $depth, $indentPad) { | |
if (-1 !== $depth) { | |
\Log::debug(str_repeat($indentPad, $depth).$line); | |
} | |
}; | |
foreach(func_get_args() as $x){ | |
$clone = $cloner->cloneVar($x); | |
$dumper->dump($clone, $logLineWriter); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment