【发布时间】:2016-04-02 16:51:47
【问题描述】:
我正在尝试调试通过proc_open 启动的 PHP 进程。这意味着脚本代码本身作为字符串通过fwrite 传递。例如。通过使用 PHPUnit 调用如下:
$php = \PHPUnit_Util_PHP::factory();
$response = $php->runJob("<?php\nrequire 'some/framework/bootstrap.php';");
您可以在GitHub 上找到相关的源代码。作为调试器,我目前使用 Xdebug 和 IDE Eclipse。
我的 Xdebug 设置如下所示:
xdebug.remote_log=/tmp/xdebug.log
xdebug.idekey=ECLIPSE_DBGP
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_host=192.168.1.80
问题是这些进程没有达到断点。当我查看日志 (/tmp/xdebug.log) 时,我看到几个像这样的 init 数据包(在 fclose($pipes[0]); 之后正好三个):
<init xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
fileuri="dbgp://stdin"
language="PHP"
protocol_version="1.0"
appid="2091"
idekey="ECLIPSE_DBGP">
<engine version="2.2.5"><![CDATA[Xdebug]]></engine>
[...]
</init>
但是 Eclipse 从来没有像从 CLI (../vendor/phpunit/phpunit/phpunit -c [...]) 对父进程那样响应:
<init xmlns="urn:debugger_protocol_v1"
xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
fileuri="file:///var/www/vendor/phpunit/phpunit/phpunit"
language="PHP"
protocol_version="1.0"
appid="2103"
idekey="ECLIPSE_DBGP">
<engine version="2.2.5"><![CDATA[Xdebug]]></engine>
[...]
</init>
所以这两个init 数据包之间的唯一区别是属性fileuri。对于通过proc_open 启动的进程,它只包含一个dbgp://stdin,这是有道理的,因为这些脚本来自一个字符串。
所以我的问题是如何让 eclipse 正确地用 fileuri="dbgp://stdin" 回复这些首字母?
似乎 Eclipse 仅在收到带有 fileuri 可以映射的 init 数据包时才响应。但是dbgp://stdin 的映射配置会是什么样子?
为了清楚起见,除了通过proc_open 启动的进程之外,我的设置完全正常且工作正常。这意味着我可以调试通过 CLI 或浏览器启动的脚本。
【问题讨论】:
标签: php eclipse phpunit xdebug