云中漫步 发表于 2015-12-24 00:00:04

在Magento开发中使用FirePHP




FirePHP是FireFox浏览器中用于PHP调试的一款基于Firebug的插件,可以使开发者像调试Js代码一样在浏览器中调试PHP代码。


1 安装步骤:
1) https://addons.mozilla.org/en-US/firefox/addon/firebug/ 安装Firebug
2) https://addons.mozilla.org/en-US/firefox/addon/firephp/ 安装FirePHP
3) http://www.firephp.org/ 下载FirePHPCoreServer Library,在FirePHPCore目录下有fb.php, fb.php4, FirePHP.class.php, FirePHP.class.php4以及LICENSE这几个文件。


2 测试
我们把FirePHPCore文件夹放到网站的根目录下,并在根目录下新建一个脚本文件如test.php


[*]warn('Warn message');
[*]$firephp->error('Error message');

具体的使用方法请参照 http://www.firephp.org/HQ/Use.htm


3 在Magento中集成FirePHP
到Magento Connect下载Magento FirePHP Extension插件,使用方法如下:


[*]Mage::helper('firephp')->send($var, $label='', $style ='LOG');
[*]Mage::helper('firephp')->debug($var, $label='', $style ='LOG');

debug 方法会检查变量是否是Varien_Object对象,并尝试使用Varien_Object->debug()来显示该变量


实例代码:


[*]Mage::helper('firephp')->send('Lorem ipsum sit amet ..');
[*]Mage::helper('firephp')->debug(Mage::getModel('catalog/product')->load(54));

此外,可以在System->Configuration->Developer->Debug->FirePHP开启活关闭FirePHP。
页: [1]
查看完整版本: 在Magento开发中使用FirePHP