Ben Rubin
Ben Rubin

Reputation: 7341

Why aren't all properties of an object being shown in the variables section in the debugger

I'm using XDebug with the Visual Studio Code debugger on some PHP code, and the Variables section is not showing all of the properties on one of my objects. The screenshot below shows that if I add $this->_data to the Watch section, that property does exist. However, _data is not shown as a property in $this in the Variables section. Why isn't Visual Studio Code showing all of the properties in $this, and how do I get it to show all of them?

enter image description here

Upvotes: 5

Views: 1538

Answers (2)

PsychoMo
PsychoMo

Reputation: 699

This issue is related to whether the attribute/field is private/protected or not.

You must tell XDebug to forward detailed information such as private fields to your IDE via the command show_hidden=1.

In VSCode with Felix Beckers php debugger extension, you can add this setting through the launch.json by adding the field xdebugSettings (see their doc for details)

The following worked for me:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9090,
            "xdebugSettings": {
                "max_children": 200,
                "max_data": 512,
                "max_depth": 4,
                "show_hidden": 1 //< show/forward private field info to the IDE
            }
        }
    ]
}

NOTE: Remote config doesn't seem to support -l for any of the above settings.

Upvotes: 8

taubi19
taubi19

Reputation: 382

You should try setting

ini_set('xdebug.var_display_max_depth', -1);
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1)

You sholud also read the explanation on xdebugs settings: https://xdebug.org/docs/all_settings

Upvotes: 0

Related Questions