Guilherme Freire
Guilherme Freire

Reputation: 372

Error on dump or dd laravel adding a character before result

All request and dumps in laravel add a ^before a result, that's only do that in dd or dump

exemple of error

exemple dd Request:all()

This effect generate a lot of errors on my code, someone past some like that?

Upvotes: 17

Views: 3916

Answers (2)

Gabriel Guzmán
Gabriel Guzmán

Reputation: 156

I had the same problem with laravel framework Lumen (5.8.12) and I solved the problem by returning to version 5.8.4.

The Origin of the problem seems to be the Symfony VarDumper Component (\vendor\symfony\var-dumper\Cloner\Data.php, line 302):

$dumper->dumpScalar($cursor, 'default', '^');

Should be:

 $dumper->dumpScalar($cursor, 'default', '');

Update

It is there for a useful reason. In terminal if you hover over the mouse on that ^ sign it will show you the file path from where this dump is coming from! I think it's really a useful thing but I don't see it working in browser. So, it should either be removed from borwser or fix the issue there.

Upvotes: 14

user12313683
user12313683

Reputation:

For simple variables, reading the output should be straightforward. Here are some examples showing first a variable defined in PHP, then its dump representation: Check This Link For Better reference

For example:

 $var = [
'a simple string' => "in an array of 5 elements",
'a float' => 1.0,
'an integer' => 1,
'a boolean' => true,
'an empty array' => [],
 ];
 dump($var);

The gray arrow is a toggle button for hiding/showing children of nested structures.

$var = "This is a multi-line string.\n";
$var .= "Hovering a string shows its length.\n";
$var .= "The length of UTF-8 strings is counted in terms of UTF-8 characters.\n";
$var .= "Non-UTF-8 strings length are counted in octet size.\n";
$var .= "Because of this `\xE9` octet (\\xE9),\n";
$var .= "this string is not UTF-8 valid, thus the `b` prefix.\n";
dump($var);

class PropertyExample
{
public $publicProperty = 'The `+` prefix denotes public properties,';
protected $protectedProperty = '`#` protected ones and `-` private ones.';
private $privateProperty = 'Hovering a property shows a reminder.';
}

$var = new PropertyExample();
dump($var);

Upvotes: -1

Related Questions