$v)
{
if ($k >= 3)
{
if (substr($v, 0, 10) == '--YII_ENV=')
{
$YII_ENV = trim(substr($v, 10));
break;
}
}
}
}
if (empty($YII_ENV)){
$YII_ENV = 'production';
}
define('YII_ENV', $YII_ENV);
// change the following paths if necessary
$yii = dirname(__FILE__) .'/../../framework/yii.php';
$config = dirname(__FILE__) .'/../config/console.'. $YII_ENV .'.php';
if ( ! file_exists($config)) exit('Configuration file does not exist!');
require_once($yii);
require_once(dirname(__FILE__) .'/../helper/yii.php');
if(isset($config))
{
$app = Yii::createConsoleApplication($config);
// $app->commandRunner->addCommands(YII_PATH .'/cli/commands');
$app->commandRunner->addCommands(dirname(dirname(__FILE__)) .'/commands');
}
else
{
// $app = Yii::createConsoleApplication(array('basePath' => dirname(__FILE__) .'/cli'));
$app = Yii::createConsoleApplication(array('basePath' => dirname(dirname(__FILE__)) .'/commands'));
}
$env = @getenv('YII_CONSOLE_COMMANDS');
if( ! empty($env))
{
$app->commandRunner->addCommands($env);
}
$app->run();