使用PHP+XDEBUG时,在VS代码中显示长字符串



我正在使用VS代码进行PHP web开发。带有XDEBUG的VS代码在显示字符串值变量方面似乎受到严重限制。Variables(变量(和Watch(监视(窗口仅限于窗口的宽度或第一个换行符。

您可以通过评估字符串在调试控制台中显示更多内容,但最多只能显示1000个字符以上的内容。字符串被简单地截断。复制值并粘贴到编辑器窗口中时也会发生同样的情况。

当使用任何一种真实的HTML时,这都是非常不恰当的。

我使用的是带有XDEBUG 1.16.1(和PHP Intelphense 1.7.1(的VS代码1.57.1

有人知道调整这个的方法吗?

答案如下:

Visual Studio代码调试阵列评估

基本上,您需要在启动配置文件中添加一个max_data: -1

例如

{
// 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"
}
}
],
}

最新更新