How to debug php fatal errors in Silex Framework

后端 未结 2 1344
自闭症患者
自闭症患者 2021-02-06 02:21

I wonder how can I see syntax errors like this (missing semicolon):


This will cause a WSOD (white screen of death

相关标签:
2条回答
  • 2021-02-06 02:52

    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();
    
    0 讨论(0)
  • 2021-02-06 02:54

    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.

    0 讨论(0)
提交回复
热议问题