簡體   English   中英

如何在Silex Framework中調試php致命錯誤

[英]How to debug php fatal errors in Silex Framework

我想知道如何看到這樣的語法錯誤(缺少分號):

<?php
var_dump($app)
?>

這將導致WSOD(白屏死機)。

我試圖包含一個調試配置文件,如下所示:

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文件中:

“symfony / debug”:“~2.3”,

但仍然沒有變化。 我忘記了什么?

試試這個:

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();

在初始化$ app之前設置錯誤處理很重要。

使用composer require symfony/debug安裝Symfony / debug composer require symfony/debug並在Silex \\ Application實例之前添加這些行

use \Symfony\Component\Debug\ErrorHandler;
use \Symfony\Component\Debug\ExceptionHandler;
ini_set('display_errors', 0);
error_reporting(-1);
ErrorHandler::register();
ExceptionHandler::register();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM