14

I'm using VS Code for PHP web development. VS Code with XDEBUG appears to be severely limited in displaying string-valued variables. The Variables and Watch windows are limited to the width of the window, or to the first new-line character.

You can display more in the Debug Console by evaluating the string, but only up to something slightly more than 1000 characters. The string is simply truncated. The same happens when you copy the value and paste in an editor window.

This is pretty inadquate when working with any kind of real-life HTML.

I'm using VS Code 1.57.1 with XDEBUG 1.16.1 (and PHP Intelephense 1.7.1)

Anybody know of a way to adjust this?

1 Answer 1

20

Here is the answer:

Visual Studio Code debugging Array evaluation

Basically you need to add a max_data: -1 to the launch configuration file.

e.g.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9004,
            "xdebugSettings": {
                "max_children": 128,
                "max_data": -1,
                "max_depth": 3
            },
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 0,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        },
        {
            "name": "Launch Built-in web server",
            "type": "php",
            "request": "launch",
            "runtimeArgs": [
                "-dxdebug.mode=debug",
                "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:0"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9004,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        }
    ],
}
Sign up to request clarification or add additional context in comments.

Comments

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.