How to debug php fatal errors in Silex Framework

我怕爱的太早我们不能终老 提交于 2019-12-03 03:12:47

Try this:

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.

Install Symfony/debug using composer require symfony/debug and add these lines before Silex\Application instance

use \Symfony\Component\Debug\ErrorHandler;
use \Symfony\Component\Debug\ExceptionHandler;
ini_set('display_errors', 0);
error_reporting(-1);
ErrorHandler::register();
ExceptionHandler::register();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!