如何在Silex Framework中调试php致命错误 [英] How to debug php fatal errors in Silex Framework
本文介绍了如何在Silex Framework中调试php致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何看到这样的语法错误(缺少分号):
I wonder how can I see syntax errors like this (missing semicolon):
<?php
var_dump($app)
?>
这将导致一个WSOD(白屏死机)。
This will cause a WSOD (white screen of death).
我尝试添加一个调试配置文件,如下所示:
I tried to include a debug config file which look like this:
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\Debug;
// Include the prod configuration
require __DIR__.'/prod.php';
// Enable PHP Error level
error_reporting(E_ALL);
ini_set('display_errors','On');
// Enable debug mode
$app['debug'] = true;
// Handle fatal errors
ErrorHandler::register();
Debug::enable();
我包含在作曲家json文件中:
I included in composer json file:
symfony / debug:〜2.3,
"symfony/debug": "~2.3",
但是还是没有变化。我忘记了什么?
But still no change. What did I forgot?
推荐答案
尝试这样:
use Symfony\Component\HttpKernel\Debug\ErrorHandler;
use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
// set the error handling
ini_set('display_errors', 1);
error_reporting(-1);
ErrorHandler::register();
if ('cli' !== php_sapi_name()) {
ExceptionHandler::register();
}
// init application
$app = new Silex\Application();
// set debug mode
$app['debug'] = true
$app->run();
在初始化$应用程序之前设置错误处理非常重要。
it's important to set the error handling before initialize the $app.
这篇关于如何在Silex Framework中调试php致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文