Yii2 has it's own error handler, that converts all non-fatal php errors into catchable exceptions.
Is it possible to use it only for handling fatal errors or (better) explicitly specify, which errors should be handled by yii error handler, and which should be processed by internal php handler?
I.e. in dev environment I want all errors to throw an exceptions and provide error page with trace.
But in prod environment I want only fatal errors to render error page with yii, but notices and warnings should just go to standard php log without throwing an exeption.
Currently if I set YII_ENABLE_ERROR_HANDLER
to true
, I get exception on notices (I do not want it on prod); if I set it to false
, I loose yii fatal error pages; and it I set it to true
and set error_reporting
to 0
, I loose error logging.
EDIT: I created a package that implements behavior described below.
Yii2's error handler cannot be configured in this way. But it is possible to create own error handler, extending
yii\web\ErrorHandler
(oryii\console\ErrorHandler
if required).Then it is possible to configure the error handler:
In this example configuration we say that error handler should always handle fatal errors, but handle catchable errors only if we are in debug mode. In production mode all catchable errors will be handled by internal php error handler and will appear in error log if you configure it.
display_errors
is said to inherit server php configuration fromphp.ini
or.htaccess
.