![](/img/trans.png)
[英]How to make Firefox Developer Tools display FirePHP messages within console?
[英]How to use firefox developer tools to log server side messages from PHP
我试图切换firefox开发人员工具进行服务器端调试,因为firebug不再使用firePHP。
查看了我发现此信息的文档:
像FirePHP这样的Firebug扩展允许将服务器端消息记录到Firebug控制台。 此功能已使用ChromeLogger协议集成到DevTools中,无需安装任何扩展。
我将chrome logger集成到我用Chrome测试过的PHP脚本中并确保它正常工作。 但是在Firefox Dev Tools上没有出现在控制台上 。 我检查了X-ChromeLogger-Data的标题。 编码数据成功传递。
任何人都有解决方案的想法?
供参考developer.mozilla.org/en-US/docs/Tools/Web_Console/Console_messages#Server
使用Firefox Developer Edition 56.0b3和ChromePhp 4.1.0(Chrome logger php脚本)测试
编辑:有一些奇怪的事情。 有两个不同的开发人员工具,一个打开F12,没有服务器选项卡,另一个通过工具> Web开发人员菜单打开
服务器选项卡不显示有关chrome logger的信息
屏幕截图在这里:
截至2017年,萤火虫和firephp已被禁用。
我对chromephp工具做了一些修改,允许从firephp无缝迁移到chromephp,以便通过控制台进行debuging。
本文以简单明了的步骤解释
作为本文详细信息的补充,您无需切换到chrome浏览器,也可以通过firefox Web控制台的服务器选项卡查看日志
使用Firefox 57,又名Firefox Quantum,看起来ChromePhp的服务器日志不再有效。
QuantumPHP是另一种选择。 使用此工具,服务器日志和JavaScript日志都显示在“控制台”下。
继Kudehinbu的工作,以及我自己的工作,即重构QuantumPHP类提供了https://github.com/frankforte/quantumphp ,为开发人员提供了一个更加无缝的方法和FirePHP的迁移过程,我也可以补充说,与FirePHP不同,当对象是info() , warn()或error()方法的参数的一部分时,客户端呈现不会超过简洁的[object Object]。
要像FirePHP那样详尽地开发一个对象,你可能想要在调用QuantumPHP类的输出方法之前使用print_r()或var_export()转换$ args ,或者更好,作为一个私有/受保护的变换器。阶级本身。
protected function resolveObjectArgs(array &$args)
{
array_walk($args, function(&$value, $key) {
if (is_array($value)) {
$value = print_r($value, true);
}
else if(is_object($value)) {
$value = var_export($value, true);
}
else return;
});
}
因此在输出方法中调用此转换器:
public function info()
{
$args = func_get_args();
$this->resolveObjectArgs($args); // <== this is the line to add to the existing code
return $this->_log(self::INFO, $args);
}
请注意,在我的重构之后, info()现在是公共的 ,不再是公共静态的 ,因为我决定使用对象上下文。
最后,利用公共上下文 ,您可能想要添加析构函数:
public function __destruct()
{
$this->send();
}
因此,在PHP脚本最后一次调用QuantumPHP方法后,可以系统地显式调用send方法。
客户端使用示例:
$QPHP = QuantumPHP::getInstance(); $Obj = new MyOwnObject(); $QPHP->info($Obj); // will eventually output a detailed structure of your object // send() gets called magically at the end of the page!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.