symfony: The function dd() is not working in laravel
Symfony version(s) affected: symfony/var-dumper:5.2 PHP version:8.0 Laravel version:8.17.2 Description
When I print the collection use the dd function, I cannot see the nested content inside the collection,like the following,
Illuminate\Database\Eloquent\Collection {#992 #items: array:9 [] }
i cant see any items,the previous version can be expanded to view specific items
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (6 by maintainers)
Like the above picture,the nested element is empty!Why???
@nicolas-grekas
I just sent PR #39523 to revert PR #35959
Hi @derrabus
I tracked down the changed behavior to this commit: https://github.com/symfony/var-dumper/commit/4b5ca0096f952ea114182b10e6d8d47c3d84ac8d
Reverting it brings the old behavior back.
Note it only happens when previewing the results of calling
dd(...)on the network tab, I tested in both Chrome and Firefox.It doesn’t need to be an AJAX call, you can preview a regular page, in the regular browser nested properties will be interactive/collapsible, while if previewing the HTML document on the developer tools’ network tab it won’t be interactive/expandable.
Previous behavior before the commit above was to have all properties expanded when previewing on the network tab.
To reproduce it you don’t need to use Laravel. You can reproduce this with the following steps:
http://localhost:8000My guess is that the commit above changed the output from expanded by default to collapsed by default. And as the network tab’s preview pane doesn’t run JavaScript the results cannot be expanded.
Users might be relying on the results to be expanded to debug AJAX calls.
Hope this helps.
Hello,
Same issue here, it apperas on axios response :
It returns
If you use dd() in for exemple web.php Laravel page, it works.
Thanks
Hi @nicolas-grekas I tried #39525 and it is working as expected regarding the network tab.
I guess, as the JavaScript code is the first thing rendered, it will also prevent any flickering reported by issue #35800.
Thanks!
All right, please help a Laravel noob like me to reproduce the problem: Please create a small application that I can run to reproduce the problem. Share that application as a GitHub repo and link it in this thread. Thanks!
Hello,
I have the same problem. I do the following line in AppServiceProvider.php
But if the same line is called through an axios call
And in preview of response in network tab of browser is the same result
In the response tab the HTML code seems to be complete
Thanks
@buffary we need to understand what happens technically first, before we can answer the why.
So any insights what’s causing length=9 but
[]for rendering is welcome.We need to isolate the problem. Maybe it can be reproduced as simple as
dd(new Collection(range(1,9)))but that’s up to you to confirm at first.A piece of code reproducing the output from the screenshot above allows others to gain such insights as well.