Steven Dawson
Steven Dawson

Reputation: 131

Remove character limit in VS Code PHPDebug

When debugging in PHP and using the variables pane on the left, there is a limit to the amount of characters you can see for that variable/object when hovering over.

Is there anyway to see the full payload for that variable or any work around other than having to use file_put_contents every time I want to see a large variable value? Also printing the variable to the debug console has the same limitation but adds one extra character (lucky me).

Upvotes: 13

Views: 7749

Answers (1)

NikoKyriakid
NikoKyriakid

Reputation: 630

In order to achieve that you need to make a change in your launch.json configuration of xdebug in VS Code.

The piece of configuration you will need to add to your configuration of launch.json is "xdebugSettings": { "max_data": -1 }

A simple configuration should look like that

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000,
        "serverSourceRoot": "/var/www/myapp/",
        "localSourceRoot": "${workspaceRoot}/",
        "xdebugSettings": {
            "max_data": -1
        }
    }]
}

xdebugSettings.max_data Controls the maximum string length that is shown when variables are displayed. To disable any limitation, use -1 as value.

Good luck.

Upvotes: 32

Related Questions