2014-04-26 21 views
7

Tôi tự hỏi làm thế nào tôi có thể thấy lỗi cú pháp như thế này (thiếu dấu chấm phẩy):Làm thế nào để gỡ lỗi php lỗi nghiêm trọng trong silex Khung

<?php 
var_dump($app) 
?> 

này sẽ gây ra một WSOD (màn hình trắng của cái chết).

tôi đã cố gắng để bao gồm một tập tin gỡ lỗi cấu hình mà trông như thế này:

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

tôi có trong nhà soạn nhạc tệp json:

"symfony/debug": "~ 2.3",

Nhưng vẫn không có thay đổi. Tôi đã quên gì?

Trả lời

13

Hãy thử điều này:

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

điều quan trọng là để thiết lập xử lý trước khi khởi tạo ứng dụng $ lỗi.

2

Cài đặt Symfony/debug sử dụng composer require symfony/debug và thêm những dòng này trước khi silex \ Application dụ

use \Symfony\Component\Debug\ErrorHandler; 
use \Symfony\Component\Debug\ExceptionHandler; 
ini_set('display_errors', 0); 
error_reporting(-1); 
ErrorHandler::register(); 
ExceptionHandler::register(); 
Các vấn đề liên quan