EDIT: I created a package that implements the behavior described below.
The Yii2 error handler cannot be configured this way. But you can create your own error handler by expanding yii\web\ErrorHandler(or yii\console\ErrorHandler, if required).
namespace app\web;
use yii\web\ErrorHandler as BaseErrorHandler;
class ErrorHandler extends BaseErrorHandler {
public $error_types;
public $display_errors = false;
private $_memoryReserve;
private $_hhvmException;
public function register()
{
$default_error_types = [ 'fatal' => true, 'catchable' => E_ALL | E_STRICT ];
$error_types = array_merge($default_error_types, (array) $this->error_types);
ini_set('display_errors', $this->display_errors);
set_exception_handler([$this, 'handleException']);
if (defined('HHVM_VERSION')) {
set_error_handler([$this, 'handleHhvmError'], $error_types['catchable']);
} else {
set_error_handler([$this, 'handleError'], $error_types['catchable']);
}
if ($this->memoryReserveSize > 0) {
$this->_memoryReserve = str_repeat('x', $this->memoryReserveSize);
}
if ($error_types['fatal']) {
register_shutdown_function([$this, 'handleFatalError']);
}
}
}
Then you can configure the error handler:
'components' => [
'errorHandler' => [
'class' => 'app\web\ErrorHandler',
'error_types' => [
'fatal' => true,
'catchable' => YII_DEBUG ? (E_ALL | E_STRICT) : false
],
'display_errors' => ini_get('display_errors')
],
],
, , , . php , .
,
display_errors php php.ini .htaccess.