我正在尝试在Codeigniter 3应用程序上设置Whoops。
我用作曲家安装了 Whoops 并像这样称呼它:
use WhoopsHandlerPrettyPageHandler;
if (ENVIRONMENT == 'development') {
$whoops = new WhoopsRun;
$whoops->pushHandler(new WhoopsHandlerPrettyPageHandler());
$whoops->register();
$handler = new PrettyPageHandler;
$handler->setEditor('sublime');
}
它适用于警告、通知和已弃用的错误,但不适用于致命错误。
CodeIgniter似乎在Whoops之前处理它们。有没有办法修改此行为?
在定义我的开发环境和错误报告设置(CI 索引中的第 70 行左右(之后,我通过在我的索引.php文件中移动"Whoops Run"来让它工作.php:
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
* 2017-08-21: Adding Whoops profiler
*/
use WhoopsHandlerPrettyPageHandler;
switch (ENVIRONMENT)
{
case 'development':
case 'staging':
error_reporting(-1);
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_WARNING ^ E_USER_WARNING ^ E_NOTICE ^ E_DEPRECATED );
$whoops = new WhoopsRun;
$whoops->pushHandler(new WhoopsHandlerPrettyPageHandler());
$whoops->register();
break;
case 'testing':
case 'production':
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>='))
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
}
else
{
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
break;
default:
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'The application environment is not set correctly.';
exit(1); // EXIT_ERROR
}
这个 Github 哎呀问题中的评论告诉我!