我在使用VSCode调试PHP时遇到问题。
Dockerfile EXPOSE端口 80
我要调试的页面非常简单:
home.php
<?php
$name = 'AAA';
echo $name; <--- here is the breakpoint
php.ini
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_port = 80
xdebug.idekey = VSCODE
launch.json (XDebug配置)
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
}
]
}
调试控制台没有显示任何错误,但是一旦加载主页,它就不会在断点处停止。
答案 0 :(得分:0)
您的remote_port
指令是错误的。
这是调试器将要监听的端口。通常是9000
。
您可以将其保留为未设置状态,并将使用该值(该值与您似乎在Visual Studio Code上使用的配置相匹配。
答案 1 :(得分:0)
您的设置可能会略有不同(因为我在Laradock内部使用了它-因此它具有Laravel的味道),但我认为配置对您有所帮助。
其中一些设置可能是多余的,但是它们是从许多教程中提取的,并且在我的Localhost设置上运行得很好。
php.ini
xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal // important if using Mac
xdebug.remote_port=9000 // important for connection to occur
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.remote_handler=dbgp
xdebug.max_nesting_level=250
xdebug.remote_log=/var/www/xdebug_log/xdebug_docker.log // for debugging Xdebug!
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"pathMappings": {
"/var/www/app": "${workspaceFolder}/app" // repoint this
},
"xdebugSettings": {
"max_data": 65535,
"show_hidden": 1,
"max_children": 100,
"max_depth": 5
}
}
]
}