Mike5050
Mike5050

Reputation: 605

How can I disable Yii error pages?

I am moving into a production environment and the following is set:

error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 0);
ini_set('log_errors', 1);
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', false);
defined('YII_ENABLE_EXCEPTION_HANDLER') or define('YII_ENABLE_EXCEPTION_HANDLER', false);

However, I have noticed that Yii will still show that big beautiful stack trace filled with all sorts of goodies.

I know the best way to overcome this is to actually write sound code, however, that is not always possible when dealing with mischievous individuals.

Using:

Apache/2.4.27 (Amazon) PHP/7.0.25
Yii Framework/2.0.8

Testing:

<?php
    ThisFunctionDoesNotExist();
?>

Although, everything seems to be correct, it doesnt work. I am having similar issues as this guy: http://www.yiiframework.com/forum/index.php/topic/22583-yii-debug-false-shows-php-notice-errors-and-stops/

Upvotes: 0

Views: 2098

Answers (1)

Patrick
Patrick

Reputation: 1338

defined('YII_ENV') or define('YII_ENV', 'prod');

http://www.yiiframework.com/doc-2.0/guide-concept-configurations.html#environment-constants

Upvotes: 2

Related Questions