Codeigniter +哎呀 [英] Codeigniter + Whoops

查看:73
本文介绍了Codeigniter +哎呀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Whoops codeigniter.com/ rel = nofollow noreferrer> Codeigniter 3 应用程序。

I'm trying to setup Whoops on a Codeigniter 3 application.

我用作曲家安装了Whoops并这样称呼:

I installed Whoops with composer and calling it like this :

use Whoops\Handler\PrettyPageHandler;
if (ENVIRONMENT == 'development') {
    $whoops = new \Whoops\Run;
    $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler());
    $whoops->register();

    $handler = new PrettyPageHandler;
    $handler->setEditor('sublime');
}

它适用于警告,通知和不建议使用的错误,但不适用于致命错误。

It works for warnings, notices and deprecated errors, but not for fatal errors.

CodeIgniter似乎可以在Whoops之前处理它们。有没有办法修改这种行为?

CodeIgniter seems to handle them before Whoops. Is there a way to modify this behavior?

推荐答案

我通过在index.php中移动 Whoops Run来使其工作文件,紧接着定义了我的开发环境和错误报告设置(在CI index.php文件中的第70行):

I got it working by moving the "Whoops Run" in my index.php file, right after defining my development environment and error reporting settings (around line 70 in the CI index.php file) :

/*
 *---------------------------------------------------------------
 * 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 Whoops\Handler\PrettyPageHandler;
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 \Whoops\Run;
        $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler());
        $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 Whoops问题提示了我!

这篇关于Codeigniter +哎呀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆