我无法在本地主机上通过CLI设置调试(在PHP Debug中启动当前打开的脚本配置)该脚本运行,但忽略任何断点。否则,在浏览器中调试PHP可以正常工作。
我的设置,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": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"externalConsole": false,
"port": 9000,
"stopOnEntry": true,
"hostname": "localhost",
"runtimeExecutable": "C:\\wamp64\\bin\\php\\php7.4.1\\php.exe",
"env": {"XDEBUG_CONFIG" : "remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"
},
"runtimeArgs": ["-dxdebug.remote_enable=1", "-dxdebug.remote_mode=req", "-dxdebug.remote_port=9000", "-dxdebug.remote_host=127.0.0.1", "-dxdebug.remote_connect_back=0"
]
}
]
}
php.ini中的Xdebug部分:
[xdebug]
zend_extension="c:/wamp64/bin/php/php7.4.1/zend_ext/php_xdebug-2.9.0-7.4-vc15-x86_64.dll"
xdebug.remote_enable = On
;xdebug.remote_autostart = 1
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.remote_log = "c:/wamp64/tmp"
;xdebug.remote_host=localhost
[您尝试从设置中看到不同的设置,但是没有用。
编辑:这是调试中的日志文件:
<- launchResponse
Response {
seq: 0,
type: 'response',
request_seq: 2,
command: 'launch',
success: true
}
<- outputEvent
OutputEvent {
seq: 0,
type: 'event',
event: 'output',
body: { category: 'stdout', output: 'gotovo!' }
}
gotovo!
<- terminatedEvent
TerminatedEvent { seq: 0, type: 'event', event: 'terminated' }
-> disconnectRequest
{
command: 'disconnect',
arguments: { restart: false },
type: 'request',
seq: 3
}
您在终端CLI上的可能性不大,因为您不使用php模块。这里仅在服务器apache或nginx中。