Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

How to fix null given error in laravel-dump-server?

Hello, I added "beyondcode/laravel-dump-server": "^1.2" to my Laravel 5.7 application and sometimes I got error

[2018-10-18 03:44:02] local.ERROR: Argument 1 passed to Symfony\Component\VarDumper\Dumper\HtmlDumper::dump() must be an instance of Symfony\Component\VarDumper\Cloner\Data, null given, called in /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php on line 47 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Argument 1 passed to Symfony\Component\VarDumper\Dumper\HtmlDumper::dump() must be an instance of Symfony\Component\VarDumper\Cloner\Data, null given, called in /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php on line 47 at /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/symfony/var-dumper/Dumper/HtmlDumper.php:111)
[stacktrace]

I run server in my console as :

php artisan dump-server --format=html > public/dump.html

I added wrapper method to common trait of my app:

<?php

namespace App\Http\Traits;

use File;
use Barryvdh\Debugbar\Facade as Debugbar;
use Carbon\Carbon;
use Config;
use Intervention\Image\Facades\Image as Image;
trait funcsTrait
{
    public function d($data)
    {

        if (empty($data)) {
            return;
        }

        dump($data);
    }

and calling this method in  my control :
     $this->d('ProfilePageTest Test51:: $newUserSessionData::' . print_r($newUserSessionData, true));

And sometimes I got error described above. In my wrapper I tried to exclude calling of dump with empty value, supposing that empty value could be reason of this error ? But looks like the reason was different. If there is a way make work it properly?

Thanks!

0 likes
2 replies
Sergiu17's avatar
public function d($data)
{
    $data && dump($data);
}
D9705996's avatar
D9705996
Best Answer
Level 51

If your having issues with null then your d function should be

    public function d($data)
    {
        if (!is_null($data)) {
            dump($data);
        }
    }
1 like

Please or to participate in this conversation.