1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #!/usr/bin/env php
- <?php
- /**
- * Yii console bootstrap file.
- *
- * @link http://www.yiiframework.com/
- * @copyright Copyright (c) 2008 Yii Software LLC
- * @license http://www.yiiframework.com/license/
- */
- const DS = DIRECTORY_SEPARATOR;
- 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.'.env';
- if (file_exists($env_file)) {
- $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');
- }
- $config_path = __DIR__ . DS.'config'.DS.'console.php';
- $config = require($config_path);
- $application = new yii\console\Application($config);
- $exitCode = $application->run();
- exit($exitCode);
|