如何详细跟踪 Slim 应用程序错误

How to Have a Detailed Trace of a Slim Application Error

我有 10000 行代码概述了我的 API 使用 Slim 框架实现的路线。但是,我收到一条错误消息 preg_match(): Compilation failed: two named subpatterns have the same name at offset 89。问题是,我在 Slim Route.php 上得到了引用此语句 preg_match('/cost-centers...', '/overview/funds...', NULL) 的堆栈跟踪。现在我的网址很长,我无法确定哪些网址具有相同的名称。

有什么方法可以得到更详细的堆栈跟踪而不是显示这些缩短的格式?

感谢 mgansler 提供此提示。

我刚刚使用了 custom error handler with PHP Exception::getTrace() 函数。我还关闭了 Slim 的默认调试,以确保调用自定义错误处理程序。

代码如下:

$app = new \Slim\Slim(array(
    'debug' => false
));
$app->error(function (\Exception $e) use ($app) {
    //enter manipulation of $e->getTrace()
    //or just var_dump($e->getTrace()) but the format would be chaotic
});