Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 596
Steven Dawson Avatar asked Aug 11 '17 11:08

Steven Dawson


People also ask

How do you change all occurrences of a word in VS Code?

Expand the Search widget to display the Replace text box. When you type text into the Replace text box, you will see a diff display of the pending changes. You can replace across all files from the Replace text box, replace all in one file or replace a single change.

What is the code for beautify code in Visual Studio?

VSCode – Code Formatting Shortcuts The code formatting is available in Visual Studio Code (VSCode) through the following shortcuts or key combinations: On Windows Shift + Alt + F. On macOS Shift + Option + F. On Linux Ctrl + Shift + I.


1 Answers

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.

like image 100
NikoKyriakid Avatar answered Sep 18 '22 01:09

NikoKyriakid