PHP Method Yii::createConsoleApplication Code Examples

This page contains top rated real world PHP examples of method Yii::createConsoleApplication extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: Initializer.php Project: 2amigos/yiinitializr
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;
 }
Example #2
Show file File: YiiHelper.php Project: sepaker/yupe
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);
     }
 }
Example #3
Show file File: YiiMTestSuite.php Project: motin/forked-php-orm-benchmark
0
 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();
 }
Example #4
Show file File: bootstrap.php Project: yiicod/mongoyii
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';
Example #5
Show file File: bootstrap.php Project: intersvyaz/yii-extended-db
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);
Example #6
Show file File: yiic.php Project: asopin/portal
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$app = Yii::createConsoleApplication(__DIR__ . '/config/console.php');
$app->commandRunner->addCommands(YII_PATH . '/cli/commands');
$app->run();
Example #7
Show file File: cron.php Project: janisto/yii-environment
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
Example #8
Show file File: cron.php Project: artmart/verare
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();
Example #9
Show file File: TestCase.php Project: igorsantos07/yii-br-pack
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);
 }
Example #10
Show file File: ComposerCallback.php Project: ZyManch/zbank
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;
 }
Example #11
Show file File: Callback.php Project: andreyantonov78/atmosphera
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;
 }
Example #12
Show file File: bootstrap.php Project: yourilima/yii-sass
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));
Example #13
Show file File: phpunit_init.php Project: anastaszor/yii1-recorditerator
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__));
Example #14
Show file File: yiic.php Project: alextravin/yupe
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();
Example #15
Show file File: yiic.php Project: wuhailin/composer
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 <qiang.xue@gmail.com>
 * @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();
Example #16
Show file File: ComposerCallback.php Project: snapfrozen/snapcms
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;
 }
Example #17
Show file File: cron.php Project: bogiesoft/yii-travel
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();
Example #18
Show file File: Application.php Project: hung5s/yap
0
 public static function createConsoleApplication($config = null)
 {
     self::loadModulesConfig($config);
     $app = Yii::createConsoleApplication($config);
     $app->getModule('Xpress');
     return $app;
 }