简体   繁体   English

自己的软件包中的调试断点:Symfony 2.7 + PHPStorm 9 + Xdebug 2.2

[英]Debug breakpoints in own bundles: Symfony 2.7 + PHPStorm 9 + Xdebug 2.2

this is the first time I try to debug a Symfony 2.7 installation with xdebug inside PHPStorm 9.0. 这是我第一次尝试在PHPStorm 9.0中使用xdebug调试Symfony 2.7安装。 Apache is running on the same system where PHPStorm is installed. Apache在安装PHPStorm的同一系统上运行。 The basic setup works so PHPStorm is connected with xdebug, breaks on the first line and stops on the next breakpoint when I press F9. 基本设置可以正常工作,因此当我按F9键时,PHPStorm与xdebug连接,在第一行中断,并在下一个断点停止。 My problem is: the debugger does not stop inside my own bundles in Symfony2. 我的问题是:调试器不会在Symfony2的我自己的捆绑软件内停止。 It seems that the Symfony2 structure "confuses" PHPStorm. 似乎Symfony2结构“混淆”了PHPStorm。 The debugger only stops in some main symfony2 files like app.php or AppKernel.php. 调试器仅在一些主要的symfony2文件(如app.php或AppKernel.php)中停止。

Let's start with my configuration: 让我们从我的配置开始:

xdebug.conf xdebug.conf

zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_log=/var/log/xdebug-remote.log
xdebug.remote_autostart=0
xdebug.var_display_max_children=512
xdebug.var_display_max_data=32000
xdebug.var_display_max_depth=8

Everything in xdebug remote log looks fine and I find all my breakpoints which I set in PHPStorm. xdebug远程日志中的所有内容看起来都很好,我发现了在PHPStorm中设置的所有断点。 I also can open files with VIM using the file:// path which I can see inside the xdebug log. 我还可以使用在xdebug日志中看到的file://路径通过VIM打开文件。

My conclusion : there is no mapping problem, right? 我的结论是 :没有映射问题,对吧? To be really save I mapped all folders in PHPStorm settings. 为了真正保存,我在PHPStorm设置中映射了所有文件夹。 It still does not work... 它仍然不起作用...

Breakpoint in symfony/app/AppKernel.php works: symfony / app / AppKernel.php中的断点有效:

<- breakpoint_set -i 11 -t line -f file:///var/www/myDomain.de/symfony/app/AppKernel.php -n 23
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="110380033"></response>

Breakpoint in own bundle in SmartphoneController.php does not work (PHPStorm debugger does not stop): SmartphoneController.php中自己的软件包中的断点不起作用(PHPStorm调试器不会停止):

<- breakpoint_set -i 12 -t line -f file:///var/www/myDomain.de/symfony/src/Pce/Bundle/BackendBundle/Controller/SmartphoneController.php -n 32
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="110380034"></response>

To be sure that the codeline is executed I saved some test string in a global $_SERVER variable: 为确保代码行已执行,我在全局$ _SERVER变量中保存了一些测试字符串:

$_SERVER['TEST_FOR_DEBUG'] = 'Am I executed? YES!';
var_dump($_SERVER['TEST_FOR_DEBUG']);

My conclusion : the xdebug - PHPStorm setup generally works (debugger stops in AppKernel.php). 我的结论是 :xdebug-PHPStorm安装程序通常可以正常工作(调试器在AppKernel.php中停止)。

Ok, maybe there is a problem with Symfonys caching and PHPStorm comes into trouble referencing the right files. 好的,也许Symfonys缓存存在问题,并且PHPStorm在引用正确的文件时遇到了麻烦。 I found these articles to disable Symfonys caching to "help the IDE": 我发现这些文章禁用了Symfonys缓存来“帮助IDE”:

Based on these articles I called the Dev-Environment (app_dev.php) and disabled the caching before: 基于这些文章,我调用了Dev-Environment(app_dev.php)并在之前禁用了缓存:

$loader = require_once __DIR__.'/../app/autoload.php';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
// CHANGE: Comment the next line to disable cache loading
//$kernel->loadClassCache();
$request = Request::createFromGlobals();

No luck! 没运气! Does anybody know what I can do? 有人知道我能做什么吗?

Thanks to LazyOne! 感谢LazyOne! I chose another line in my Controller where a simple variable is set. 我在控制器中选择了另一行,其中设置了一个简单变量。 I spent many hours trying to understand why the debugger does not stop at a part of my code where a lot of Doctrine objects are handled. 我花了很多时间试图理解为什么调试器不会在我处理很多Doctrine对象的代码部分不停止。 Maybe to complex for PHPStorm. 也许对于PHPStorm来说很复杂。

Read the comments of my question: 阅读我的问题的评论:

  • try xdebug_break(); 尝试xdebug_break();
  • set breakpoint on "simple" code lines 在“简单”代码行上设置断点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM