Add server variable condition for ./web/index.php
& ./yii
:
if (isset($_SERVER['APP_ENV']) && $_SERVER['APP_ENV']=='production') {
// Default is PROD
} else {
// DEV
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
}
After that, you can switch environment easiliy.
Nginx for example, set server variable into the site:
location ~ \.php$ {
# ENV Setting
fastcgi_param APP_ENV 'production';
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
Add server variable setting before yii
console:
APP_ENV="production" ./yii controller/action