Home » Php » Laravel/PHP dd() displays non-structured arrays in Chrome developer tools

Laravel/PHP dd() displays non-structured arrays in Chrome developer tools

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have noticed that writing in Laravel’s Controller:

dd($array) 

outputs an un-structured view of array in Chrome Developer Tools (chome 61.0.3163.91 64-bit, MAC OS).

enter image description here

before it was something like this (at least it seems to me that it was like this):
enter image description here

Do I have ‘false memories’?

OR, if dd() really outputted structured arrays in devtools, how do I bring it back?

How to&Answers:

I’ve posted the same question in official chrome bugs forum https://bugs.chromium.org/p/chromium/issues/detail?id=767386#c5
they said that it’d be corrected in Chrome 62 released on 17-OCT-2017, which is… TODAY:)

Answer:

I’m using Chrome Version 63.0.3239.132 (Official Build) (64-bit) and still have the issue.

Workaround until the bug is fixed.

http_response_code(500);
dd('foo');

Turn it into a helper function ddd

1) Create a file called helpers.php in app/Http

2) Past the following in:

<?php 

function ddd(...$args){
    http_response_code(500);
    call_user_func_array('dd', $args);
}

3) In composer.json, in the autoload section, add "files": ["app/Http/helpers.php"]

4) Run composer dump-autoload command in terminal