Ejemplo n.º 1
0
 /**
  * @param $root
  * @param string $configName
  * @param mixed $mergeWith
  * @return mixed
  * @throws Exception
  */
 public static function create($root, $configName = 'main', $mergeWith = array('common', 'env'))
 {
     if (($root = realpath($root)) === false) {
         throw new Exception('could not initialize framework.');
     }
     $config = self::config($configName, $mergeWith);
     $class = Config::value('yiinitializr.app.classes.' . $configName);
     if ($class && !is_callable($class)) {
         throw new Exception('yiinitializr.app.classes.' . $configName . ' class must be callable.');
     }
     if (php_sapi_name() !== 'cli') {
         // aren't we in console?
         $app = $class ? $class($config) : \Yii::createWebApplication($config);
     } else {
         defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
         $app = $class ? $class($config) : \Yii::createConsoleApplication($config);
         $app->commandRunner->addCommands($root . '/cli/commands');
         $env = @getenv('YII_CONSOLE_COMMANDS');
         if (!empty($env)) {
             $app->commandRunner->addCommands($env);
         }
     }
     //  return an app
     return $app;
 }
Ejemplo n.º 2
0
 public function createConsoleYiiApp()
 {
     require dirname(__FILE__) . '/../../vendor/autoload.php';
     $config = (require dirname(__FILE__) . '/../../protected/config/console-test.php');
     \Yii::$enableIncludePath = false;
     if (!\Yii::app()) {
         \Yii::createConsoleApplication($config);
     }
 }
 public function initialize()
 {
     //        require_once "vendor/autoload.php";
     define('YII_DEBUG', false);
     require_once "vendor/yiisoft/yii/framework/yii.php";
     $app = Yii::createConsoleApplication(array('basePath' => dirname(__FILE__), 'import' => array('application.models.*')));
     Author::$db = Book::$db = $this->db = new CDbConnection('sqlite::memory:');
     $this->db->active = true;
     Author::createTable();
     Book::createTable();
 }
Ejemplo n.º 4
0
<?php

define('YII_PATH', realpath(__DIR__ . '/../../../yiisoft/yii/framework'));
// disable Yii error handling logic
defined('YII_ENABLE_EXCEPTION_HANDLER') or define('YII_ENABLE_EXCEPTION_HANDLER', false);
defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', false);
define('APP_ROOT', realpath(__DIR__ . '/../../../../app/protected'));
define('APP_RUNTIME', APP_ROOT . '/runtime');
define('APP_ASSETS', APP_ROOT . '/assets');
// composer autoloader
require_once __DIR__ . '/../../../autoload.php';
require_once YII_PATH . '/yii.php';
$env = @getenv('YII_MONGOYII_ENV');
if ($env) {
    $env = unserialize($env);
} else {
    $env = [];
}
Yii::createConsoleApplication(CMap::mergeArray(['name' => 'test', 'basePath' => APP_ROOT, 'runtimePath' => APP_RUNTIME, 'aliases' => ['mongoyii' => realpath(__DIR__ . '/../')], 'import' => ['mongoyii.*', 'mongoyii.behaviors.*', 'mongoyii.util.*', 'mongoyii.validators.*'], 'components' => ['mongodb' => ['class' => 'mongoyii.EMongoClient', 'db' => 'mongoyii-fake', 'server' => 'mongodb://10.8.4.114:27017'], 'authManager' => ['class' => 'mongoyii.util.EMongoAuthManager']]], $env));
// See the `Boostrap.init()` method for explanation why it is needed
define('IS_IN_TESTS', true);
require_once 'models/User.php';
require_once 'models/UserTsTest.php';
require_once 'models/Interest.php';
require_once 'models/Dummy.php';
require_once 'models/Skill.php';
require_once 'models/versionedDocument.php';
Ejemplo n.º 5
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/yiisoft/yii/framework/yiit.php';
$config = array('basePath' => __DIR__ . DIRECTORY_SEPARATOR . '..', 'aliases' => ['fakes' => __DIR__ . '/fakes'], 'components' => array('db' => array('class' => '\\Intersvyaz\\ExtendedDb\\DbConnection', 'connectionString' => 'sqlite:' . __DIR__ . DIRECTORY_SEPARATOR . 'test.db')));
Yii::createConsoleApplication($config);
// fix Yii's autoloader (https://github.com/yiisoft/yii/issues/1907)
Yii::$enableIncludePath = false;
Yii::import('fakes.*');
// create DUAL table
$db = new PDO($config['components']['db']['connectionString']);
$db->exec('CREATE TABLE IF NOT EXISTS dual(a PRIMARY KEY)');
$db->exec('insert OR IGNORE into dual values(1)');
unset($db);
Ejemplo n.º 6
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$app = Yii::createConsoleApplication(__DIR__ . '/config/console.php');
$app->commandRunner->addCommands(YII_PATH . '/cli/commands');
$app->run();
Ejemplo n.º 7
0
<?php

/**
 * This is the bootstrap file for console application.
 */
// Set environment
require_once dirname(__FILE__) . '/protected/extensions/environment/Environment.php';
$env = new Environment();
$env->init();
Yii::createConsoleApplication($env->console)->run();
// When you execute a PHP script from the command line, it inherits the environment variables defined in your shell.
// That means you can set an environment variable using the export command like so:
// export YII_ENVIRONMENT='TEST'
// Shell: php /path/to/cron.php command
Ejemplo n.º 8
0
<?php

defined('YII_DEBUG') or define('YII_DEBUG', true);
// including Yii
require_once '/framework/yii.php';
// we'll use a separate config file
$configFile = dirname(__FILE__) . '/protected/config/console.php';
// creating and running console application
Yii::createConsoleApplication($configFile)->run();
Ejemplo n.º 9
0
 /**
  * Populates Yii::$app with a new application
  */
 protected function mockApplication()
 {
     static $config = array('id' => 'testapp', 'basePath' => __DIR__);
     Yii::createConsoleApplication($config);
     Yii::setPathOfAlias('vendor', VENDOR);
 }
Ejemplo n.º 10
0
 /**
  * Creates console application, if Yii is available
  */
 private static function getYiiApplication()
 {
     if (!is_file(YII_PATH . '/yii.php')) {
         return null;
     }
     require_once YII_PATH . '/yii.php';
     spl_autoload_register(array('YiiBase', 'autoload'));
     if (\Yii::app() === null) {
         $config = (require_once dirname(__FILE__) . '/../config/console.php');
         $staticConfig = (require_once dirname(__FILE__) . '/../config/static_config.php');
         require_once dirname(__FILE__) . '/../merge.php';
         $mergedConfig = array_merge_config($staticConfig, $config);
         if ($mergedConfig) {
             $app = \Yii::createConsoleApplication($mergedConfig);
         } else {
             throw new \Exception("File from CONSOLE_CONFIG not found");
         }
     } else {
         $app = \Yii::app();
     }
     return $app;
 }
Ejemplo n.º 11
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.º 12
0
<?php

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii/framework/yii.php';
$basePath = sys_get_temp_dir() . '/yii-sass';
if (!is_dir($basePath)) {
    if (!mkdir($basePath)) {
        throw new Exception('Can not create directory: ' . $basePath);
    }
}
Yii::createConsoleApplication(array('basePath' => $basePath));
Ejemplo n.º 13
0
<?php

echo __FILE__ . ' loaded.' . "\n\n";
$vendordir = __DIR__ . DIRECTORY_SEPARATOR . 'vendor';
require $vendordir . DIRECTORY_SEPARATOR . 'autoload.php';
// workaround to not have yii's autoloader fail when phpunit tries to load
// Php_Invoker.php which is not provided.
Yii::$enableIncludePath = false;
$rclass = new ReflectionClass('YiiBase');
$rprop = $rclass->getProperty('_includePaths');
$rprop->setAccessible(true);
$rprop->setValue(null, array());
Yii::createConsoleApplication(array('basePath' => __DIR__));
Ejemplo n.º 14
0
<?php

require dirname(__FILE__) . '/../vendor/autoload.php';
$yiic = (require dirname(__FILE__) . '/../vendor/yiisoft/yii/framework/yii.php');
$config = (require dirname(__FILE__) . '/config/console.php');
$configManager = new yupe\components\ConfigManager();
$configManager->sentEnv(\yupe\components\ConfigManager::ENV_CONSOLE);
$app = \Yii::createConsoleApplication($configManager->merge($config));
$app->commandRunner->addCommands(YII_PATH . '/cli/commands');
$app->run();
Ejemplo n.º 15
0
<?php

/**
 * Yii command line script file.
 *
 * This script is meant to be run on command line to execute
 * one of the pre-defined console commands.
 *
 * @author    Qiang Xue <*****@*****.**>
 * @link      http://www.yiiframework.com/
 * @copyright 2008-2013 Yii Software LLC
 * @license   http://www.yiiframework.com/license/
 */
// fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('YII_DEBUG') or define('YII_DEBUG', true);
require_once $env->yiiPath;
$env->setAlias();
if (isset($config)) {
    $app = Yii::createConsoleApplication($config);
    $app->commandRunner->addCommands(YII_PATH . '/cli/commands');
} else {
    $app = Yii::createConsoleApplication(array('basePath' => dirname(__FILE__) . '/cli'));
}
$env = @getenv('YII_CONSOLE_COMMANDS');
if (!empty($env)) {
    $app->commandRunner->addCommands($env);
}
$app->run();
Ejemplo n.º 16
0
 /**
  * Creates console application, if Yii is available
  */
 private static function getYiiApplication()
 {
     if (!is_file(YII_PATH . '/yii.php')) {
         return null;
     }
     require_once YII_PATH . '/yii.php';
     spl_autoload_register(array('YiiBase', 'autoload'));
     if (\Yii::app() === null) {
         if (is_file(CONSOLE_CONFIG)) {
             $app = \Yii::createConsoleApplication(CONSOLE_CONFIG);
         } else {
             throw new \Exception("File from CONSOLE_CONFIG not found");
         }
     } else {
         $app = \Yii::app();
     }
     return $app;
 }
Ejemplo n.º 17
0
<?php

date_default_timezone_set('Europe/Moscow');
chdir(dirname(__FILE__) . '/');
$root = dirname(dirname(__FILE__)) . '/';
$common = $root . '/framework';
require_once $common . '/yii.php';
$config = (require 'config/cron.php');
$app = Yii::createConsoleApplication($config)->run();
Ejemplo n.º 18
0
 public static function createConsoleApplication($config = null)
 {
     self::loadModulesConfig($config);
     $app = Yii::createConsoleApplication($config);
     $app->getModule('Xpress');
     return $app;
 }