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)

Commits related to this issue

Most upvoted comments

82325B631CF65E09B34539CC1B0D9253

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:

mkdir test
cd test
composer init
composer require symfony/var-dumper
echo "<?php require __DIR__ . '/vendor/autoload.php'; dd(['foo' => [1,2,3]]);" > index.php
php -S localhost:8000
  • Navigate to http://localhost:8000
  • Output on browser should be as expected (expandable/collapsible)
  • Open developer tools (I tested on Chrome and Firefox)
  • Select the Network tab
  • Click the HTML response
  • The preview panel will show the response collapsed

My 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 :

dump(['test0' => ['test1' => 'test1', 'test2' => 'test2']]);

It returns

image

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

dd(config('applications.forms.app_name.beneficiary_forms'));

image

But if the same line is called through an axios call

image

And in preview of response in network tab of browser is the same result

image

In the response tab the HTML code seems to be complete image

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.