我有一个使用教义2的zend项目。
我的问题是我无法禁用敏感数据的错误。(即当数据库连接失败时会显示错误,包括密码)。
到目前为止,我尝试的是更改公用文件夹中的 index.php 文件,如下所示:
<?php
//Disable all error reporting
error_reporting(0); //Somehow this doesn't work
ini_set('display_errors', false); //Somehow this doesn't work
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
}
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
try{
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
}
catch(Exception $ex){
echo 'server error!';//This code is never reached although a PDOException is thrown!
}
我需要做什么来禁用此类错误并隐藏敏感数据?