我是 xdebug 世界的新手,因此下面的设置大部分是从教程中复制的。不幸的是,PHP 调试并没有开始工作。不要停在断点处。我不明白缺少什么。
我的设置: VS代码机:192.168.1.220
开发网站(网站功能齐全):
本地地址:192.168.1.182:8100 或 http://myNasServer:8100,\
公共 phpinfo(反向代理“Nginx 代理管理器”):https://intranet.adplus.ee/info.php
该网站在 docker 容器中运行,并使用 PHP 5.6.40(这是一个旧应用程序,需要此 php)
Docker-compose 文件:
version: '2.2'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: my_secret_pw_shh
MYSQL_DATABASE: test_db
MYSQL_USER: devuser
MYSQL_PASSWORD: devpass
ports:
- "9906:3306"
volumes:
- ./dbdata:/var/lib/mysql
command: --sql_mode=""
web:
container_name: php_web
build:
context: ./php
dockerfile: Dockerfile
depends_on:
- db
volumes:
- ./php/intra/:/var/www/html/
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
ports:
- "8100:80"
stdin_open: true
tty: true
local.ini 文件中的 XDEBUG 配置(Netbeans 建议配置)
[xdebug]
zend_extension="xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9003
xdebug.idekey="netbeans-xdebug"
xdebug.remote_log="./xdebug.log"
xdebug.show_exception_trace=1
Vs Code 启动配置
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html/": "${workspaceFolder}"
},
"log": true
},
{
"name": "Lauch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003,
}
]
}
您的 Xdebug 配置使用 Xdebug 2 的所有内容,而不是您最有可能使用的 3。您需要更新的教程,或阅读升级指南。
我还建议您阅读 Xdebug 网站上的官方文档:https://xdebug.org/docs/step_debug — 其中还链接到一个 5 分钟的视频,介绍如何使用 Docker:https:// /www.youtube.com/watch?v=ZIGdBSD6zvU