问题
I have 10000 lines of code outlining routes of my API implemented using the Slim Framework. However, I got an error message preg_match(): Compilation failed: two named subpatterns have the same name at offset 89
. The problem is, I got the stack trace referring to this statement preg_match('/cost-centers...', '/overview/funds...', NULL)
at the Slim Route.php. Now that my URLs are lengthy, I can't pinpoint which of the URLs have the same name.
Is there any way to have a more detailed stack trace instead of displaying these shortened format?
回答1:
Thanks to mgansler for this tip.
I just used a custom error handler with PHP Exception::getTrace() function. I also turned the Slim's default debugging off to ensure that the custom error handler is invoked.
Code goes like this:
$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
});
来源:https://stackoverflow.com/questions/32452479/how-to-have-a-detailed-trace-of-a-slim-application-error