13

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).

1
  • You should probably file an issue on the extension for this, but it's probably a limitation somewhere else and not an arbitrary limit. Commented Aug 13, 2017 at 6:54

1 Answer 1

32

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.

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

6 Comments

With value of -1 my xDebug just froze and was not able to display any variables. I tried value of 8192 (totally arbitrary) and then it worked.
@BigBob Yes of course. -1 will remove any limitation and that could slow down when debugging huge variables. So choosing an arbitrary number would improve speed. A smaller number means better performance as xDebug doesn't have to present any variable that is huge. It will cut it's content to the size you have specified by the arbitrary number.
+1. Still the popup showing when hovering over variables is cut short. If only there were a way to know that it has been cut off or not.
@Jonny I hope you've since found a solution, however, if your IDE has a debug terminal you should be able to enter the variable into the terminal and get its full value.
This is the correct option just the WRONG value.-1 slows the debugging process with all variables... for me at least.
|

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.