我非常绝望并且没有想法:
我已经为 Laravel 3 项目配置了 xdebug 和 PhpStorm。在 Mac OS X Apache 上本地运行该项目,因此 PhpStorm 和 Web 应用程序在同一台计算机上运行。配置虚拟主机,使 localhost.lt 指向 Laravel 的公共目录。
php.ini 中的相关 xdebug 条目:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
[xdebug]
xdebug.idekey="PHPSTORM"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_log=/var/log/xdebug_remote.log
xdebug.remote_connect_back=1
确认扩展已加载。
设置 PHP Web 应用程序调试/运行配置,无需任何路径映射,因为没有任何符号链接,并且 Web 服务器上的文件夹和 PhpStorm 上的文件夹完全相同(因为 Web 服务器位于同一台计算机上)。
当从 IDE 中通过“调试”启动时,xdebug_remote.log 正确显示我们在应用程序/库中的文件之一中设置的断点:
<- breakpoint_set -i 5 -t line -f
file:///Users/RalfR/src/livetime/application/libraries/LiveTime.php -n 676
->
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="9230016"></response>
但是,当我们单击从 LiveTime.php 库调用该函数的链接时,不会命中断点。日志显示:
<- stack_get -i 6 ->
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="6"><stack where="{main}" level="0" type="file" filename="file:///Users/RalfR/src/livetime/public/index.php" lineno="14"></stack></response>
<- run -i 7 ->
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="stopping" reason="ok"></response>
<- run -i 8
Log closed at 2013-04-22 21:03:57
与许多框架一样,Laravel 使用 .htaccess mod_rewrite 通过 public/index.php 传输所有内容。这可能是 PhpStorm / xdebug 未捕获 application/libraries/LiveTime.php 中的断点的原因,因为 xdebug 似乎从未执行 LiveTime.php 脚本?
如果是这样,我们该如何解决这个问题呢?