45

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?

Chen Leikehmacher
  • 1,337
  • 1
  • 11
  • 13
  • 4
    Possible duplicate of [How to get xdebug var\_dump to show full object/array](https://stackoverflow.com/questions/9998490/how-to-get-xdebug-var-dump-to-show-full-object-array) – Phiter Apr 10 '18 at 11:14
  • 2
    Check out the possible duplicate. You may have limited those values. – Phiter Apr 10 '18 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. – Chen Leikehmacher Apr 10 '18 at 12:21
  • Awesome! Add this as an answer to your question. Try adding a link to the their github information. https://github.com/felixfbecker/vscode-php-debug#supported-launchjson-settings – Phiter Apr 10 '18 at 13:34

1 Answers1

80

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.

Chen Leikehmacher
  • 1,337
  • 1
  • 11
  • 13
  • 13
    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` – Jules Colle Sep 19 '19 at 16:36
  • 1
    Great! Thank you i've got many headaches while debugging other things in vscode. Finally, found array[35] has a value :) – O.k Jan 15 '20 at 14:27
  • Thanks @Jules Colle :-), that should be part of the answer. – Daniel Katz Jul 13 '20 at 17:52
  • 5
    I ran into an issue while looking at some long strings, you can set `max_data` to `-1` to disable any limits. – Sir CodesALot Sep 17 '20 at 03:41
  • This was really helpful. Thank you. – kaeland Dec 10 '20 at 19:23