我安装了 Visual Studio 代码 1.41.1 和 PHP 调试版本 - 1.13.0。
https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
我在 Ubuntu 上运行 PHP Lamp 堆栈,我的 PHP 信息显示“xdebug xdebug support enabled - Version 2.9.0”
我的 PHP.ini 配置如下:
[XDebug]
zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_handler = dbgp
;xdebug.remote_host = 192.168.1.103
xdebug.remote_port=9000
xdebug.remote_log=/var/log/xdebug.log
我的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,
"hostname": "192.168.1.23"
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"hostname": "192.168.1.23"
}
]
}
我的服务器在 192.168.1.23 上运行,我的 ide 在 192.168.1.103 上运行。
日志文件似乎写得很慢——我不确定是哪个事件触发了日志中的事件。我怀疑它是直接从我的远程主机而不是通过 Visual Studio Code 访问网页。
我还将我的 Windows Defender 防火墙设置为在端口 9000 上打开。
根据评论进行编辑。192.168.1.103 是运行 Visual Studio 代码的 windows 10 机器的 IP 地址。该机器还运行版本 6.0.8 r130520 (Qt5.6.2),虚拟机的 IP 地址为 192.168.1.23。
我已将超时更新为 2000 毫秒。
我观察到,如果我关闭虚拟机,VSC 会尝试连接并继续尝试连接更长的时间。然后虚拟机启动,它会立即出错。这表明虚拟机阻塞了端口?
最后——是什么触发进入 xdebug.log。只是在网站上加载一个 PHP 文件会触发输出记录器吗?我问的原因是我无法辨别触发错误,但是在时间增量之间打开日志文件,即今天与昨晚,产生了各种错误?
机器和虚拟机在基于路由器的防火墙之后都是安全的,因此这不会是外部流量。
虚拟机按预期在 Windows 10 客户端计算机上运行。只是无法连接调试器。但是 PHP/MYSQL/APACHE 都运行正常。
哆啦的时光机
三国纷争