首页 > 解决方案 > 在多用户环境中使用 XDebug

问题描述

我正在与其他人共享本地服务器上进行开发。该服务器有一个 Apache/PHP 实例,但它有多个“可用站点”(VirtualHost)供不同的人使用。

我想让 XDebug 工作,这样我们每个人都可以独立使用它。问题是,如果我们启用 XDebug,例如,我的 IDE 连接到服务器并且我设置了一个断点,那么如果其他人正在浏览该页面,它就会停止,即使它在他/她自己的 VirtualHost 中。

关于如何正确设置的任何提示?

编辑:

忘了提到网络服务器是在 Docker 中运行的。这是 XDebug 的当前配置:

# automatically start debugger on every request
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9000

# send all debug requests to 127.0.0.1
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal

#log all xdebug requests to see is it working correctly
xdebug.remote_log=/var/log/debug.log

谢谢。

标签: apache2xdebugvhosts

解决方案


这根本不应该发生,除非您已xdebug.remote_autostart打开进行了硬编码xdebug.remote_host(而不是使用xdebug.remote_connect_back)。您真的不想xdebug.remote_host在多用户环境中硬编码。

调试会话仅在检测到 XDEBUG_SESSION_START(这是浏览器扩展将设置的内容,或者将其添加到 GET/POST 参数时)以及继续请求时才初始化。

也没有这样的概念:

我的 IDE 已连接到服务器

在每次请求时,Xdebug(如果设置为使用 cookie 触发)将连接IDE。它使用xdebug.remote_host设置或推断的 IP 地址(如果xdebug.remote_connect_back已启用连接. 请求结束,该连接被切断。您可以使用xdebug.remote_log=/tmp/xdebug.log创建一个日志文件,该文件将指示何时建立连接,以及它们是否有效。


推荐阅读