mercredi 17 octobre 2018

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

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 commom 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!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire