Ejemplo n.º 1
0
 /**
  * Creates console application, if Yii is available
  */
 private static function getYiiApplication()
 {
     if (!is_file(Config::value('yii.path') . '/yii.php')) {
         // nothing yet installed, return
         return null;
     }
     require_once Config::value('yii.path') . '/yii.php';
     spl_autoload_register(array('YiiBase', 'autoload'));
     if (\Yii::app() === null) {
         if (!Config::value('envlock')) {
             $env = Console::prompt('Please, enter your environment -ie. "dev | prod | stage": ', array('default' => 'dev'));
             Initializer::buildEnvironmentFiles($env);
         } else {
             Console::output("\n%Benv.lock%n file found. No environment request required.\n");
             Console::output("Note: if you wish to re-do enviroment setting merging, please remove the %Benv.lock%n file " . "from the Yiinitializr %Bconfig%n folder.");
         }
         Initializer::createRuntimeFolders();
         Initializer::createRuntimeFolders('assets');
         if (is_file(Config::value('yiinitializr.config.console'))) {
             $app = \Yii::createConsoleApplication(Config::value('yiinitializr.config.console'));
         } else {
             throw new \Exception("'yiinitializr.config.console' setting not found");
         }
     } else {
         $app = \Yii::app();
     }
     return $app;
 }
Ejemplo n.º 2
0
 /**
  * Outputs text only to console
  * @param $message
  */
 protected static function output($message)
 {
     if (php_sapi_name() === 'cli') {
         Console::output($message);
     }
 }