Skip to content

Instantly share code, notes, and snippets.

@MightyPork
Last active March 26, 2019 02:55
Show Gist options
  • Select an option

  • Save MightyPork/f70e46aea90778e9709910f29d1abc60 to your computer and use it in GitHub Desktop.

Select an option

Save MightyPork/f70e46aea90778e9709910f29d1abc60 to your computer and use it in GitHub Desktop.
Automatically expand your dd()
<?php
// PUT THIS IN bootstrap/autoload.php (at the end)
/** auto-expand DD */
function dd()
{
array_map(function ($x) {
(new Illuminate\Support\Debug\Dumper)->dump($x);
}, func_get_args());
// Added to auto-expand dd() output
if (PHP_SAPI !== 'cli') {
echo "<script>
function sf_toggle(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass;
if ('sf-dump-compact' == oldClass) {
arrow = '&#9660;';
newClass = 'sf-dump-expanded';
} else if ('sf-dump-expanded' == oldClass) {
arrow = '&#9654;';
newClass = 'sf-dump-compact';
} else {
return false;
}
a.lastChild.innerHTML = arrow;
s.className = newClass;
if (recursive) {
try {
a = s.querySelectorAll('.' + oldClass);
for (s = 0; s < a.length; ++s) {
if (a[s].className !== newClass) {
a[s].className = newClass;
a[s].previousSibling.lastChild.innerHTML = arrow;
}
}
} catch (e) {}
}
return true;
}
var tg = document.querySelector('.sf-dump-toggle');
sf_toggle(tg, true);
sf_toggle(tg, true);
</script>";
}
die(1);
}
@mike-code
Copy link
Copy Markdown

Doesn't work if you have more than 1 argument passed to the dd()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment