123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- const DS = DIRECTORY_SEPARATOR;
- // 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');
- require __DIR__ . '/../vendor/autoload.php';
- require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
- $env='prod';
- $env_file = __DIR__ . DS . '..' . DS . '.env';
- if (file_exists($env_file)) {
- $env_content = trim(file_get_contents($env_file));
- $parameters_pairs = explode("\r\n", $env_content);
- $params = [];
- $env = [];
- $lines = explode(PHP_EOL,trim(file_get_contents($env_file)));
- foreach ($lines as $line){
- $pair = explode("=",$line);
- $env[$pair[0]]=$pair[1];
- defined($pair[0]) or define($pair[0], $pair[1]);
- }
- if(\yii\helpers\ArrayHelper::getValue($env,'ENV',false) && $env['ENV']=="dev"){
- $env = "dev";
- defined('YII_DEBUG') or define('YII_DEBUG', true);
- defined('YII_ENV') or define('YII_ENV', 'dev');
- defined('YII_ENV_DEV') or define('YII_ENV_DEV', 'dev');
- }
- if(isset($env['ENV'])){
- $env = $env['ENV'];
- } else {
- $env = "prod";
- }
- } else {
- defined('YII_DEBUG') or define('YII_DEBUG', false);
- defined('YII_ENV') or define('YII_ENV', 'prod');
- }
- if (file_exists(__DIR__ . DS . '..' . DS . 'revision.php')) {
- require_once(__DIR__ . DS . '..' . DS . 'revision.php');
- }
- if (!defined('REV')) {
- define('REV', 1);
- }
- $config_path = __DIR__ . DS.'..'.DS.'config'.DS.'env'.DS.$env.'.php';
- $config = require($config_path);
- $config = require __DIR__ . '/../config/web.php';
- (new yii\web\Application($config))->run();
|