如何详细记录Slim应用程序错误

问题描述 投票:0回答:2

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

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

slim
2个回答
1
投票

感谢mgansler的建议。

我刚刚在PHP custom error handler()函数中使用了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
});

0
投票

使用

`$config = ['settings' => [
        'addContentLengthHeader' => true,
        'displayErrorDetails' => true
    ]];
    $app = new \Slim\App($config)`
© www.soinside.com 2019 - 2024. All rights reserved.