Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code debugging Array evaluation

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?

like image 291
Chen Leikehmacher Avatar asked Apr 10 '18 11:04

Chen Leikehmacher


People also ask

How do you start a Debug session to evaluate expressions?

To open the Debug Console, use the Debug Console action at the top of the Debug pane or use the View: Debug Console command (Ctrl+Shift+Y). Expressions are evaluated after you press Enter and the Debug Console REPL shows suggestions as you type.

How can I see the variable value while debugging in Visual Studio?

When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

How do you display results in output VS Code?

To open the Output window, on the menu bar, choose View > Output, or press Ctrl+Alt+O.

How can I see Debug logs in VS Code?

You can find other debug logs you've downloaded with Visual Studio Code in the . sfdx/tools/debug/logs folder. Right-click any line in the debug log, then choose SFDX: Launch Apex Replay Debugger with Current File.


1 Answers

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.

like image 191
Chen Leikehmacher Avatar answered Sep 18 '22 08:09

Chen Leikehmacher