E
E
evilelf2015-12-31 09:59:08
Yii
evilelf, 2015-12-31 09:59:08

How to change mode in yii2?

When installing Yii2, I made the Development mode.
How to switch to Production?
And how to manage these modes?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
bears, 2015-12-31
@bears

In web/index.php you need to comment out the lines:

// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

and there will be a prod environment

E
Evgeny Bukharev, 2015-12-31
@evgenybuckharev

there is an init file in the root of the project, run from the console, and select the production environment, just check the configs in the environments folder

@
@profluck, 2019-05-20
_

Simple solution with Yii2 basic deployment, check environment by IP in /web/index.php file

if($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_ENV') or define('YII_ENV', 'dev');
}

In the case of Yii2 advanced, the init file, as Evgeny Bukharev wrote above

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question