Display Laravel's dd() results without die -> d(), dump() in blade
Asked Answered
A

1

13

I want to display the content of my session with the same style that the dd() function.

I try to do this :

<div>
    {!! dump(session()->all()) !!}
</div>

And i get this error :

Facade\Ignition\Exceptions\ViewException
Array to string conversion

I don't understand why, because dump() should be able to display an array, no ?

How can i manage this ? Thanks

Aut answered 14/1, 2020 at 12:51 Comment(2)
in blade there are @dump() and @dd()Visional
dd is dump and die. This should be used for debugging not to display resultsMaggi
M
27
<?php dump(session()->all()) ?>

This is how you can display array in blade.

The { } are used to echo results (simple strings, integers etc etc) but as you know not suitable for arrays.

Maggi answered 14/1, 2020 at 12:57 Comment(1)
in addition you're basically double echo'ing when you do {{ dump() }}, since dump itself already outputs.Fishgig

© 2022 - 2024 — McMap. All rights reserved.