5

有什么方法可以告诉 HHVM 将 Hacklang 警告和错误输出到浏览器中?像 PHP 一样的东西 enabled display_errorsdisplay_startup_errorserror_reporting设置为E_ALL

HHVM 版本:

$ php -v

HipHop VM 3.1.0-dev+2014.04.09 (rel)
Compiler: heads/master-0-g4fc811c64c23a3686f66a2bea80ba47f3eaf9f3d
Repo schema: 79197c935790c0b9c9cb13566c3e727ace368117

我尝试了以下配置:

$ cat /etc/hhvm/php.ini
; php options
display_startup_errors = On
error_reporting = E_ALL
display_errors = On

; hhvm specific 
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false

和 :

$ cat /etc/hhvm/server.ini 

; php options
pid = /var/run/hhvm/pid

; hhvm specific 
hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
hhvm.mysql.typed_results = false
hhvm.debug.full_backtrace = true
hhvm.debug.server_stack_trace = true
hhvm.debug.server_error_message = true
hhvm.debug.translate_source = true
4

1 回答 1

4

tl;博士:你不能。

这里要记住的是,类型检查器会对您的代码进行静态分析,而您谈论的 PHP 错误会在运行时出现。如果这是 C++,您可以将 Hack 类型检查器错误与编译步骤中的错误进行比较——因此 Hack 在代码运行之前就告诉您错误的事情。

诀窍是使用vim 或 emacs插件,它们会在您保存文件时警告您错误,或者hh_client从终端使用,或者为您最喜欢的 IDE 构建插件(随意发送拉取请求!)。hh_client --json如果你想为 Sublime Text、Eclipse 或任何你想要的东西构建一个插件,它提供了一个易于解析的输出。

请注意,有些错误是运行时错误,而有些则不是。例如,对于最新的 HHVM 构建,函数 args 和返回类型应该在运行时抛出异常。那里的问题是,当您点击某个代码路径时,您只会看到这些错误。Hack 的美妙之处在于它会为代码中的所有问题出错,即使它是您可能无法在运行时测试的代码路径。

于 2014-04-10T19:30:14.837 回答