Skip to content

Instantly share code, notes, and snippets.

@unstoppablecarl
Created April 29, 2015 17:44
Show Gist options
  • Save unstoppablecarl/ac28abe60d9686e6a8f3 to your computer and use it in GitHub Desktop.
Save unstoppablecarl/ac28abe60d9686e6a8f3 to your computer and use it in GitHub Desktop.
<?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