简体   繁体   English

Magento-在Netbeans中调试phtml文件

[英]Magento - Debug phtml file in Netbeans

Perhaps this question has been asked before but I cannot find it anywhere. 也许以前有人问过这个问题,但我找不到任何地方。 I am a newbie on Magento/Netbeans. 我是Magento / Netbeans的新手。

After setting up xdebug in Netbeans, I was able to start debugging by stopping at a line in index.php, say, for this line: 在Netbeans中设置xdebug之后,我能够通过在index.php中的一行停止进行启动调试,例如:

Mage::run($mageRunCode, $mageRunType);

Where I can check the values of $mageRunCode and $mageRunType. 在这里可以检查$ mageRunCode和$ mageRunType的值。

However, after setting up a breakpoint in a .phtml file, the process runs through the breakpoint without stopping at it. 但是,在.phtml文件中设置断点后,该过程将贯穿该断点而不会在断点处停止。 For example, in the file \\default\\template\\catalog\\product\\list.phtml, I set a breakpoint at (I want to step into getPriceHtml() function): 例如,在文件\\ default \\ template \\ catalog \\ product \\ list.phtml中,我在以下位置设置了一个断点(我想进入getPriceHtml()函数):

<?php echo $this->getPriceHtml($_product, true); ?>

I even set some breakpoints in the function 我什至在函数中设置了一些断点

public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')

in Abstract.php, but it did not stop either. 在Abstract.php中,但也没有停止。

So, what do I need to do to have the debug process stop at any breakpoints in Netbeans with XDebug? 因此,使用XDebug在Netbeans中的任何断点处停止调试过程都需要做什么?

It is possible to stop at breakpoints in phtml files, I do it all the time. 我可以一直在phtml文件中的断点处停止。
What could be happening, is that the code where you put the breakpoint is not executed. 可能发生的情况是,放置断点的代码未执行。 The list.phtml file, manages both the grid and the list view modes: maybe you put the breakpoint in the grid part and were watching the list view, or vice versa. list.phtml文件同时管理网格和列表视图模式:也许您将断点放在网格部分并正在监视列表视图,反之亦然。 Or maybe you're not in the right template: to be sure, enable the template hints and check the path of the file. 也许您不在正确的模板中:请确保启用模板提示并检查文件的路径。
As for the Mage_Catalog_Block_Product_Abstract::getPriceHtml() maybe it is overriden by some other class. 至于Mage_Catalog_Block_Product_Abstract::getPriceHtml()也许它被其他类覆盖。

My advice, for the list.phtml file (when you are sure it's the correct one, cfr template hints), is to put a breakpoint at the first php line, in version 1.7.0.2's native file it would be line 35: 对于list.phtml文件(当您确定它是正确的cfr模板提示时),我的建议是在1.7.0.2版本的本机文件的第一行php处放置一个断点,将其放在第35行:

$_productCollection=$this->getLoadedProductCollection();

and when you get there use the " Step Over (F8) " function until you reach the line you want to examine, ie <?php echo $this->getPriceHtml($_product, true) ?> , and there you can " Step Into (F7) " it and you will get directly to the actual function. 当你到达那里使用“ 跳过(F8)”功能,直到你达到你想要检查的行,即<?php echo $this->getPriceHtml($_product, true) ?> ,在那里你可以“ 步骤进入(F7) “它,您将直接进入实际功能。

HTH HTH

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

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