Last active
March 26, 2019 02:55
-
-
Save MightyPork/f70e46aea90778e9709910f29d1abc60 to your computer and use it in GitHub Desktop.
Automatically expand your dd()
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 | |
| // 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 = '▼'; | |
| newClass = 'sf-dump-expanded'; | |
| } else if ('sf-dump-expanded' == oldClass) { | |
| arrow = '▶'; | |
| 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); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work if you have more than 1 argument passed to the dd()