PhpUnit目前没有显示代码中出现的错误的堆栈跟踪。
我如何配置它才能做到这一点呢?
发布于 2011-07-07 17:55:57
当php没有提供堆栈转储时,我发现这是一种很蹩脚但却很有效的方法。我在一个名为DebugUtil的类中有这个。
/**
* This is for use when you have the UBER-LAME...
* "PHP Fatal error: Maximum function nesting level of '100' reached,
* aborting! in Lame.php(1273)
* ...which just craps out leaving you without a stack trace.
* At the line in the file where it finally spazzes out add
* something like...
* DebugUtil::dumpStack('/tmp/lame');
* It will write the stack into that file every time it passes that
* point and when it eventually blows up (and probably long before) you
* will be able to see where the problem really is.
*/
public static function dumpStack($fileName)
{
$stack = "";
foreach (debug_backtrace() as $trace)
{
if (isset($trace['file']) &&
isset($trace['line']) &&
isset($trace['class']) &&
isset($trace['function']))
{
$stack .= $trace['file'] . '#' .
$trace['line'] . ':' .
$trace['class'] . '.' .
$trace['function'] . "\n";
}
}
file_put_contents($fileName, $stack);
}
https://stackoverflow.com/questions/5994729
复制相似问题