46

I have a small issue when debugging PHP with Visual Studio Code. The XDebug works fine, I am able to stop at breakpoints and evaluate variables by hovering on them or adding them to watch. However when I attempt to view an array which has more than 32 items, I can only see those first 32. For example, an array of 172 items will only display 32 items. I tried to evaluate this array in a manner of ways, running dump commands inside the console, or json_encode, to no avail.

Any ideas?

4
  • 4
    Possible duplicate of How to get xdebug var_dump to show full object/array Commented Apr 10, 2018 at 11:14
  • 2
    Check out the possible duplicate. You may have limited those values. Commented Apr 10, 2018 at 11:15
  • 2
    Excellent! That helped me solve my problem. Initially changing the config file didn't change anything, however I went to the Visual Studio XDebug extension (felixbecker.php-debug) details, and it was described how to override these settings when running through Visual Code, by changing the launch.json settings. Commented Apr 10, 2018 at 12:21
  • Awesome! Add this as an answer to your question. Try adding a link to the their github information. github.com/felixfbecker/… Commented Apr 10, 2018 at 13:34

1 Answer 1

82

Thanks to Phiter's comment, I managed to find a fix.

Essentially, XDebug can be configured with various options placed inside the file php.ini. Among these options are those which specify the depth of an object to display on the GUI.

However, when debugging through Visual Code's PHP Debug (felixbecker.php-debug) extension, these settings must be configured elsewhere. The full instructions are listed on this page: https://github.com/felixfbecker/vscode-php-debug#supported-launchjson-settings The gist of it is to open the Debug panel on the left bar -> click on the cogwheel icon to open the launch.json file which houses the debugger's settings, and -> add the following code snippet:

{ "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000, "xdebugSettings": { "max_children": 999, } },

That's it.

Sign up to request clarification or add additional context in comments.

4 Comments

Had a very similar problem. However, in my case it was not the amount of children that was the problem, it was the depth of the objects/arrays. My arrays would only show 1 level deep So apart from adding "max_children": 999 I also had to add "max_depth": 10
Great! Thank you i've got many headaches while debugging other things in vscode. Finally, found array[35] has a value :)
Thanks @Jules Colle :-), that should be part of the answer.
I ran into an issue while looking at some long strings, you can set max_data to -1 to disable any limits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.