joe*_*han 9 php apache xampp xdebug visual-studio-code
我的 php.ini 配置:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.mode = debug
xdebug.remote_autostart = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/xampp/tmp"
xdebug.show_local_vars=0
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9003
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_log="c:/xampp/tmp/xdebug.log"
Run Code Online (Sandbox Code Playgroud)
我的 launch.json 配置:
{
// 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": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
Run Code Online (Sandbox Code Playgroud)
但我仍然在 error.log 中收到此错误:
[php:notice] [pid 9388:tid 1840] [client ::1:63322] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost/online-store/admin/types/insert-types.php
Run Code Online (Sandbox Code Playgroud)
首先我使用了端口 9000,但它不起作用,然后我尝试将 php.ini 和 launch.json 中的端口更改为 9003,与错误日志中的端口相同,但仍然没有任何反应,并且 XDebug 不工作并且不停止断点。
Rom*_*iaz 29
在将我的 Xdebug 库更新到 3+ 版本后,我也遇到了这样的错误。
我发现新设置xdebug.start_with_request = yes将 Xdebug 配置为对每个请求建立连接。
同时,官方文档xdebug.start_with_request = trigger仅在明确指出需要时才提供连接 Xdebug 的使用。在这种情况下,我可以通过 GET 参数传递一个额外的键来开始逐步调试过程,但这http://localhost/?XDEBUG_TRIGGER=1对我来说很不方便,我只想在 VSCode 中按 F5 开始调试,就像我一直做的那样。
所以我的解决方案如下。我离开start_with_request = yes并通过传递 关闭了大部分 Xdebug 通知xdebug.log_level = 0。log_level然后我在文件内覆盖launch.json以启用所有警告,但仅限于调试会话内。
php.ini:
[XDebug]
zend_extension = php_xdebug-3.0.4-7.4-vc15-x86_64.dll
xdebug.mode = debug,develop
xdebug.discover_client_host = yes
xdebug.log_level = 0
xdebug.log = "%sprogdir%/userdata/temp/xdebug/log.txt"
xdebug.start_with_request = yes
xdebug.idekey = VSCODE
Run Code Online (Sandbox Code Playgroud)
启动.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"env": {
"XDEBUG_CONFIG": "log_level=7",
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28401 次 |
| 最近记录: |