When using the dd
helper, i often wanted to dump multiple times in a loop and abort afterwards.
So how about adding a "dump without die()" helper?
if (! function_exists('d')) {
/**
* Dump the passed variables.
*
* @param mixed
* @return void
*/
function d()
{
array_map(function ($x) {
(new Dumper)->dump($x);
}, func_get_args());
}
}
There is the dump
function from symfony/var-dumper
as well.
@h4cc I too find myself with the same need.
+1
Can we close this? We have dump
already and 2 PR's for this were closed, #11882 and #11949.
Yep, does not seem to get accepted.
@h4cc Thanks for the function.
I was also looking for this - the documentation under Helpers only suggests dd()
.
I've placed a PR in docs to alleviate this issue reoccurring, but I'm not sure if it is the best place.
PR laravel/docs#2145
if (!function_exists('dd')) {
function dd(...$vars)
{
foreach ($vars as $v) {
VarDumper::dump($v);
}
exit(1);
}
}
dd in dump.php, you create new helper.php and delete exit(1) in your project
if (!function_exists('dd')) {
function dd(...$vars)
{
foreach ($vars as $v) {
VarDumper::dump($v);
}
}
}
Most helpful comment
There is the
dump
function fromsymfony/var-dumper
as well.