-->

hhvm-fastcgi is not showing warnings

2019-05-15 09:32发布

问题:

I'm using HHVM 3.1.0 (rel) with Nginx, and fastcgi is not showing warnings, but running hhvm on console it shows. Is it normal?

My php.ini:

error_reporting = E_ALL
display_errors = 1

hhvm.error_handling.call_user_handler_on_fatals = false
hhvm.error_handling.max_loop_count = 0
hhvm.error_handling.no_infinite_recursion_detection = false
hhvm.error_handling.throw_bad_type_exceptions = true
hhvm.error_handling.throw_too_many_arguments = true
hhvm.error_handling.warn_too_many_arguments = true
hhvm.error_handling.throw_missing_arguments = true
hhvm.error_handling.throw_invalid_arguments = true
hhvm.error_handling.enable_hip_hop_errors = true
hhvm.error_handling.notice_frequency = 1
hhvm.error_handling.warning_frequency = 1

hhvm.debug.full_backtrace = true
hhvm.debug.server_stack_trace = true
hhvm.debug.server_error_message = true
hhvm.debug.translate_source = true

回答1:

Well I had the same issue, stack question

After a lot of digging I found the problem. There is no error_handler set for HHVM. So you need to set your own.

I wrote a simple one that looks like the one of PHP, not complete though ie the error levels

set_error_handler(function ($errorNumber, $message, $errfile, $errline) {
    switch ($errorNumber) {
        case E_ERROR :
            $errorLevel = 'Error';
            break;

        case E_WARNING :
            $errorLevel = 'Warning';
            break;

        case E_NOTICE :
            $errorLevel = 'Notice';
            break;

        default :
            $errorLevel = 'Undefined';
    }

    echo '<br/><b>' . $errorLevel . '</b>: ' . $message . ' in <b>'.$errfile . '</b> on line <b>' . $errline . '</b><br/>';
});