断点没有被xdebug,PhpStorm和Laravel 3击中/mod_rewrite [英] Breakpoints not hit with xdebug, PhpStorm and Laravel 3 / mod_rewrite

查看:126
本文介绍了断点没有被xdebug,PhpStorm和Laravel 3击中/mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常绝望,没精打采了:

I'm pretty desperate and running out of ideas:

我已经为Laravel 3项目配置了xdebug和PhpStorm.在Mac OS X Apache上本地运行项目,因此PhpStorm和Web应用程序在同一台计算机上运行.配置了一个虚拟主机,以便localhost.lt指向Laravel的公共目录.

I've configured xdebug and PhpStorm for a Laravel 3 project. Running the project locally on Mac OS X Apache, so PhpStorm and the web application run on the same machine. Configured a virtual host so that localhost.lt points to Laravel's public directory.

php.ini中的相关xdebug条目:

Relevant xdebug entries in php.ini:

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服务器位于同一台机器上).

Set up a PHP Web Application debug / run configuration without any path mappings as nothing is symlinked and the folders on the web server and for PhpStorm are exactly the same (as the web server is on the same machine).

从IDE通过调试"启动时,xdebug_remote.log正确显示了我们在应用程序/库中的文件之一中设置的断点:

When launching via "Debug" from the IDE, xdebug_remote.log correctly shows the breakpoint we've set in one of the files in application/libraries:

<- 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库调用该函数的链接时,未命中断点.日志显示:

However, when we click a link that invokes the function from the LiveTime.php library, the breakpoint is NOT hit. The log shows:

<- 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脚本吗?

As many frameworks, Laravel uses .htaccess mod_rewrite to pipe everything through public/index.php. May this be the cause for PhpStorm / xdebug not catching the breakpoint in application/libraries/LiveTime.php as it appears to xdebug that the LiveTime.php script is never executed?

如果是这样,我们如何解决这个问题?

If so, how can we solve this problem?

推荐答案

您需要设置
注意2:上面显示的图像不是来自上述步骤中提到的设置"对话框,而是来自"Resovle路径"映射问题"对话框,为您提供相同的地图映射小部件,其工作方式相同.在这两个地方修复设置都可以.如果您没有任何服务器调试设置开始,并且IDE检测到映射问题,则将出现解决路径映射问题"对话框.届时,它还将为您创建服务器设置.

You need to set the Path Mappings You don't need to set it for each file. To resolve my issue, I went to the IntelliJ (same for PHPStorm) Preferences > PHP > Servers .. selected my server and set the following (see note 2 below):



NOTE 1: I could also have set the path directly to the project root, but since I am not interested in debugging anything other than my Laravel "public" folder and my application, I only set paths for those 2 folders. After this everything worked perfectly.

NOTE 2: The image shown above is not from the "Settings" dialog referred to in the steps above, but rather from the "Resovle Path Mapping Problem" dialog which presents you with the same map mappings widget which works the same way. Fixings the settings in either place will work. The Resolve Path Mapping Problem dialog will appear if you have no server debug settings to start with and the IDE detects a mapping problem, at which point it will also create the server settings for you.

这篇关于断点没有被xdebug,PhpStorm和Laravel 3击中/mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆