PHP Method Yii::createWebApplication Code Examples

This page contains top rated real world PHP examples of method Yii::createWebApplication 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: EActiveRecordRelationBehaviorTest.php Project: janym/angular-yii
0
 /**
  * set up environment with yii application and migrate up db
  */
 public function setUp()
 {
     $basePath = dirname(__FILE__) . '/tmp';
     if (!file_exists($basePath)) {
         mkdir($basePath, 0777, true);
     }
     if (!file_exists($basePath . '/runtime')) {
         mkdir($basePath . '/runtime', 0777, true);
     }
     // create webapp
     if (\Yii::app() === null) {
         \Yii::createWebApplication(array('basePath' => $basePath));
     }
     \CActiveRecord::$db = null;
     if (!isset($_ENV['DB']) || $_ENV['DB'] == 'sqlite') {
         if (!$this->dbFile) {
             $this->dbFile = $basePath . '/test.' . uniqid(time()) . '.db';
         }
         \Yii::app()->setComponent('db', new \CDbConnection('sqlite:' . $this->dbFile));
     } elseif ($_ENV['DB'] == 'mysql') {
         \Yii::app()->setComponent('db', new \CDbConnection('mysql:dbname=test;host=localhost', 'root'));
     } elseif ($_ENV['DB'] == 'pgsql') {
         \Yii::app()->setComponent('db', new \CDbConnection('pqsql:dbname=test;host=localhost', 'postgres'));
     } else {
         throw new \Exception('Unknown db. Only sqlite, mysql and pgsql are valid.');
     }
     // create db
     $this->migration = new EActiveRecordRelationBehaviorTestMigration();
     $this->migration->dbConnection = \Yii::app()->db;
     $this->migration->up();
 }
Example #3
Show file File: SettingsController.php Project: lhfcainiao/basic
0
 public function actionClearFrontend()
 {
     $local = (require './protected/config/main-local.php');
     $base = (require './protected/config/main.php');
     $config = CMap::mergeArray($base, $local);
     Yii::setApplication(null);
     Yii::createWebApplication($config)->cache->flush();
     $this->redirect('index');
 }
Example #4
Show file File: index.php Project: jralison/chrono
0
 /**
  * Executa as operações de inicialização.
  */
 public static final function init()
 {
     self::defineConstants();
     self::includeFrameworkLib();
     self::checkExtraConfigFiles();
     // Inicializa
     $config = APP_ROOT . '/configs/mainConfig.php';
     if (!is_readable($config)) {
         self::initError('O arquivo de configurações está inacessível.');
     } else {
         Yii::createWebApplication($config)->run();
     }
 }
Example #5
Show file File: ShellCommand.php Project: upmunspel/abiturient
0
    /**
     * Execute the action.
     * @param array $args command line parameters specific for this command
     */
    public function run($args)
    {
        if (!isset($args[0])) {
            $args[0] = 'index.php';
        }
        $entryScript = isset($args[0]) ? $args[0] : 'index.php';
        if (($entryScript = realpath($args[0])) === false || !is_file($entryScript)) {
            $this->usageError("{$args[0]} does not exist or is not an entry script file.");
        }
        // fake the web server setting
        $cwd = getcwd();
        chdir(dirname($entryScript));
        $_SERVER['SCRIPT_NAME'] = '/' . basename($entryScript);
        $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
        $_SERVER['SCRIPT_FILENAME'] = $entryScript;
        $_SERVER['HTTP_HOST'] = 'localhost';
        $_SERVER['SERVER_NAME'] = 'localhost';
        $_SERVER['SERVER_PORT'] = 80;
        // reset context to run the web application
        restore_error_handler();
        restore_exception_handler();
        Yii::setApplication(null);
        Yii::setPathOfAlias('application', null);
        ob_start();
        $config = (require $entryScript);
        ob_end_clean();
        // oops, the entry script turns out to be a config file
        if (is_array($config)) {
            chdir($cwd);
            $_SERVER['SCRIPT_NAME'] = '/index.php';
            $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
            $_SERVER['SCRIPT_FILENAME'] = $cwd . DIRECTORY_SEPARATOR . 'index.php';
            Yii::createWebApplication($config);
        }
        restore_error_handler();
        restore_exception_handler();
        $yiiVersion = Yii::getVersion();
        echo <<<EOD
Yii Interactive Tool v1.1 (based on Yii v{$yiiVersion})
Please type 'help' for help. Type 'exit' to quit.
EOD;
        $this->runShell();
    }
Example #6
Show file File: server.php Project: mgcxy/yiiSwoole
0
 public function __construct()
 {
     $http = new swoole_http_server("0.0.0.0", 9501);
     $http->set(array('worker_num' => 10, 'daemonize' => false, 'max_request' => 10000, 'dispatch_mode' => 1));
     $http->on('WorkerStart', array($this, 'onWorkerStart'));
     $http->on('request', function ($request, $response) {
         if (isset($request->server)) {
             HttpServer::$server = $request->server;
             foreach ($request->server as $key => $value) {
                 $_SERVER[strtoupper($key)] = $value;
             }
         }
         if (isset($request->header)) {
             HttpServer::$header = $request->header;
         }
         if (isset($request->get)) {
             HttpServer::$get = $request->get;
             foreach ($request->get as $key => $value) {
                 $_GET[$key] = $value;
             }
         }
         if (isset($request->post)) {
             HttpServer::$post = $request->post;
             foreach ($request->post as $key => $value) {
                 $_POST[$key] = $value;
             }
         }
         ob_start();
         //实例化yii对象
         try {
             $this->application = Yii::createWebApplication(FRAMEWORK_CONFIG);
             $this->application->run();
         } catch (Exception $e) {
             var_dump($e);
         }
         $result = ob_get_contents();
         ob_end_clean();
         $response->end($result);
         unset($result);
         unset($this->application);
     });
     $http->start();
 }
Example #7
Show file File: EActiveRecordRelationBehaviorTest.php Project: kostya1017/our
0
 /**
  * set up environment with yii application and migrate up db
  */
 public function setUp()
 {
     $basePath = dirname(__FILE__) . '/tmp';
     if (!file_exists($basePath)) {
         mkdir($basePath, 0777, true);
     }
     if (!file_exists($basePath . '/runtime')) {
         mkdir($basePath . '/runtime', 0777, true);
     }
     if (!$this->db) {
         $this->db = $basePath . '/test.' . uniqid(time()) . '.db';
     }
     // create webapp
     if (\Yii::app() === null) {
         \Yii::createWebApplication(array('basePath' => $basePath));
     }
     \CActiveRecord::$db = null;
     \Yii::app()->setComponent('db', new \CDbConnection('sqlite:' . $this->db));
     // create db
     $this->migration = new EActiveRecordRelationBehaviorTestMigration();
     $this->migration->dbConnection = \Yii::app()->db;
     $this->migration->up();
 }
Example #8
Show file File: index.php Project: alexey-tichonoff/accounting-system
0
<?php

// change the following paths if necessary
$yii = dirname(__FILE__) . '/../yiiframework/yii-1.1.14.f0fee9/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $yii;
Yii::createWebApplication($config)->run();
Example #9
Show file File: index.php Project: laiello/what-i-need
0
<?php

$webRoot = dirname(__FILE__);
// Если хост равен localhost, то включаем режим отладки и подключаем отладочную
// конфигурацию
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
    define('YII_DEBUG', true);
    defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
    require_once $webRoot . '/yii/framework/yii.php';
    $configFile = $webRoot . '/protected/config/dev.php';
} else {
    error_reporting(E_ALL & ~E_NOTICE);
    define('YII_DEBUG', true);
    defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
    require_once $webRoot . '/yii/framework/yiilite.php';
    $configFile = $webRoot . '/protected/config/production.php';
}
$app = Yii::createWebApplication($configFile)->run();
Example #10
Show file File: index.php Project: RonLab1987/43berega
0
<?php

/**
 * Входной скрипт index:
 *
 * @category YupeScript
 * @package  YupeCMS
 * @author   Yupe Team <team@yupe.ru>
 * @license  https://github.com/yupe/yupe/blob/master/LICENSE BSD
 * @link     http://yupe.ru
 **/
// подробнее про index.php http://www.yiiframework.ru/doc/guide/ru/basics.entry
if (!ini_get('date.timezone')) {
    date_default_timezone_set('Europe/Moscow');
}
// Setting internal encoding to UTF-8.
if (!ini_get('mbstring.internal_encoding')) {
    @ini_set("mbstring.internal_encoding", 'UTF-8');
    mb_internal_encoding('UTF-8');
}
// две строки закомментировать на продакшн сервере
define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require __DIR__ . '/../vendor/yiisoft/yii/framework/yii.php';
$base = (require __DIR__ . '/../protected/config/main.php');
$confManager = new yupe\components\ConfigManager();
$confManager->sentEnv(\yupe\components\ConfigManager::ENV_WEB);
require __DIR__ . '/../vendor/autoload.php';
Yii::createWebApplication($confManager->merge($base))->run();
Example #11
Show file File: index.php Project: rizaldi-github/yii-menu-module
0
<?php

/**
 * Test Web Entry Script
 *
 * @author Brett O'Donnell <cornernote@gmail.com>
 * @author Zain Ul abidin <zainengineer@gmail.com>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-email-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-email-module/master/LICENSE
 *
 * @package yii-email-module
 */
// define paths
define('BASE_PATH', realpath(__DIR__ . '/..'));
define('VENDOR_PATH', realpath(BASE_PATH . '/../vendor'));
define('YII_PATH', realpath(VENDOR_PATH . '/yiisoft/yii/framework'));
// debug
define('YII_DEBUG', true);
// composer autoloader
require_once VENDOR_PATH . '/autoload.php';
// create application
require_once YII_PATH . '/yii.php';
Yii::createWebApplication(BASE_PATH . '/_config.php')->run();
Example #12
Show file File: index.php Project: haanhman/rateapp
0
<?php

require_once 'define.php';
$config = ROOT_PATH . '/protected/config/fontend.php';
// create a Web application instance and run
Yii::createWebApplication($config)->runEnd('fontend');
Example #13
Show file File: index.php Project: kosenka/yboard
0
<?php

header("Content-Type: text/html; charset=UTF-8");
if ($_COOKIE['YII_DEBUG'] === "true") {
    // Подключение параметров для режима отладки
    $yii = dirname(__FILE__) . '/../framework/yii.php';
    $CONFIG = dirname(__FILE__) . '/protected/config/main_dev.php';
    //Настройка вывода сообщений
    error_reporting(E_ALL ^ E_NOTICE);
    ini_set("display_errors", 1);
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
} else {
    // Подключение стандартных параметров
    $yii = dirname(__FILE__) . '/framework/yii.php';
    $CONFIG = dirname(__FILE__) . '/protected/config/main.php';
    // Отключение вывода сообщений
    error_reporting(E_WARNING);
    ini_set("display_errors", 0);
}
require_once $yii;
Yii::createWebApplication($CONFIG)->run();
Example #14
Show file File: bootstrap.php Project: handita/ServicesSPPKS
0
<?php

error_reporting(E_ALL | E_STRICT);
require dirname(__FILE__) . '/../../../../../framework/yiit.php';
require dirname(__FILE__) . '/ResultPrinter.php';
Yii::createWebApplication(require dirname(__FILE__) . '/../../../config/main.php');
Example #15
Show file File: index.php Project: DmitrySM/PHPJobOffer
0
//директория ядра фреймворка
$frameworkFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'YiiBase.php';
//проверяем существование локального конфига
$localConfigFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.php';
file_exists($localConfigFile) && is_readable($localConfigFile) or die('Local config file not exist');
//основной конфиг
$mainConfigFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
//определяем необходимо ли включать режим дебага или нет. Включить можно перегрузив в local.php директиву params[debugMode]
if (($localConfigFileInclude = (require $localConfigFile)) && isset($localConfigFileInclude['params']['debugMode'])) {
    //подключение режима DEBUG для ловли ошибок и исключений
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    //константа уровня трассировки
    defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', isset($localConfigFileInclude['params']['debugTraceLevel']) ? $localConfigFileInclude['params']['debugTraceLevel'] : 3);
}
//подключаем ядро фреймворка
require_once $frameworkFile;
//небольшой хак для автокомплита в шторме
class Yii extends YiiBase
{
    /**
     * @static
     * @return MyCWebApplication
     */
    public static function app()
    {
        return parent::app();
    }
}
//создаем веб-приложение и запускаем его
Yii::createWebApplication($mainConfigFile)->run();
Example #16
Show file File: index.php Project: rosko/AlmazService
0
<?php

require_once dirname(__FILE__) . './../../vendors/yii-1.1.8/framework/yii.php';
$app = Yii::createWebApplication(dirname(__FILE__) . '/protected/config/config.php');
$app->run();
Example #17
Show file File: protected.tests.bootstrap.php Project: alejandrososa/ventasYii
0
<?php

require '../vendor/autoload.php';
// set environment
$env = new \marcovtwout\YiiEnvironment\Environment('TEST');
//override mode
// run Yii app
require_once $env->yiitPath;
require_once dirname(__FILE__) . '/WebTestCase.php';
Yii::createWebApplication($env->configWeb);
Example #18
Show file File: Bootstrap.php Project: petrgrishin/yii-url-builder
0
<?php

/**
 * @author Petr Grishin <petr.grishin@grishini.ru>
 */
require_once __DIR__ . '/../vendor/autoload.php';
class Yii extends YiiBase
{
    /**
     * Автолоадер совместимый с composer
     * @author Petr Grishin <petr.grishin@grishini.ru>
     * @param string $alias
     * @param bool $forceInclude
     * @return mixed
     */
    public static function import($alias, $forceInclude = false)
    {
        $arguments = func_get_args();
        return @call_user_func_array(array(get_parent_class(), 'import'), $arguments) ?: $arguments[0];
    }
}
Yii::createWebApplication(array('basePath' => './tests'));
spl_autoload_unregister(array('YiiBase', 'autoload'));
Example #19
Show file File: index.php Project: xsir317/5zer
0
<?php

// 在生产环境中请删除此行
//defined('YII_DEBUG') or define('YII_DEBUG', TRUE);
// 时区设置
date_default_timezone_set('Asia/Shanghai');
include dirname(dirname(__FILE__)) . '/framework/yiilite.php';
Yii::createWebApplication('./protected/config/main.php')->run();
Example #20
Show file File: employee.php Project: qhyabdoel/hris_mujigae
0
<?php

// change the following paths if necessary
$yii = dirname(__FILE__) . '/../yii/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/employee.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $yii;
require_once 'lib/global.php';
Yii::createWebApplication($config)->runEnd('employee');
Example #21
Show file File: index.php Project: BanNT/xechieuve
0
<?php

// change the following paths if necessary
$yii = dirname(__FILE__) . '/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/user.php';
// Remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $yii;
Yii::createWebApplication($config)->runEnd('user');
Example #22
Show file File: admin.php Project: arduanov/eco
0
<?php

/*
 * @author: Kirilov Eldar
 * @company: reaktive
 * @comment: manage singelton
 *
 */
$yii = dirname(__FILE__) . '/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/backend.php';
/*
*  framework have two mode
* 1 - Debug
* 2 - Production
*
*/
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
define('YII_ENABLE_ERROR_HANDLER', false);
require_once $yii;
Yii::createWebApplication($config)->runEnd('backend');
Example #23
Show file File: index.php Project: mohdhise/phpmark
0
<?php

// include Yii bootstrap file
require_once dirname(__FILE__) . '/framework/yii.php';
// create a Web application instance and run
Yii::createWebApplication()->run();
Example #24
Show file File: app.php Project: Bitcoinsulting/yiimp
0
<?php

require_once 'framework-1.0.8/yii.php';
require_once 'yaamp/include.php';
$app = Yii::createWebApplication('yaamp/config.php');
Example #25
Show file File: index.php Project: urichalex/CS-Bans
0
<?php

/**
 * Индекс
 */
/**
 * @author Craft-Soft Team
 * @package CS:Bans
 * @version 1.4.0
 * @copyright (C)2016 Craft-Soft.ru.  Все права защищены.
 * @link http://craft-soft.ru/
 * @license http://creativecommons.org/licenses/by-nc-sa/4.0/deed.ru  «Attribution-NonCommercial-ShareAlike»
 */
date_default_timezone_set('Europe/Moscow');
// Дебаг
defined('YII_DEBUG') or define('YII_DEBUG', true);
// Кол-во стак трейсов ошибок
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
// Ядро
require_once __DIR__ . '/include/yii/framework/yii.php';
// Создаем приложение
Yii::createWebApplication(__DIR__ . '/protected/config/main.php')->run();
Example #26
Show file File: backend.php Project: andrelinoge/rezydent
0
<?php

define('APPLICATION_END', 'backend');
// change the following paths if necessary
$rootDir = dirname(__FILE__);
$yii = $rootDir . '/framework/yii.php';
$config = $rootDir . '/application/protected/config/backend.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once 'shortcuts.php';
require_once $yii;
Yii::createWebApplication($config)->runEnd(APPLICATION_END);
Example #27
Show file File: index.php Project: subhra-sekhar/yiitest
0
<?php

// change the following paths if necessary
$yii = dirname(__FILE__) . '/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/front.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $yii;
Yii::createWebApplication($config)->runEnd('front');
Example #28
Show file File: bootstrap.php Project: nov072008/yiitesting
0
<?php

// change the following paths if necessary
require dirname(__FILE__) . '/../../../../../framework/yiit.php';
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . "/../" . PATH_SEPARATOR . dirname(__FILE__) . "/fixtures/models/");
//require(dirname(__FILE__).'/../WForm.php');
//require(dirname(__FILE__).'/../WFormBehavior.php');
//require(dirname(__FILE__).'/../WFormBehavior.php');
//$config=dirname(__FILE__).'/../config/test.php';
//
Yii::createWebApplication(array('basePath' => dirname(__FILE__) . '/fixtures/'));
Example #29
Show file File: bootstrap.php Project: kl0428/admin
0
<?php

// change the following paths if necessary
$yiit = dirname(__FILE__) . '/../../../../下载/yii-1.1.16.bca042/framework/yiit.php';
$config = dirname(__FILE__) . '/../config/test.php';
require_once $yiit;
require_once dirname(__FILE__) . '/WebTestCase.php';
Yii::createWebApplication($config);
Example #30
Show file File: index.php Project: lp19851119/114la
0
    $http_host .= '/';
}
if (substr($dt_root, -1) != '/') {
    $dt_root .= '/';
}
if (substr($sst_filename, -1) != '/') {
    $sst_filename .= '/';
}
$siteUrl = str_replace(array($dt_root), array('https://' . $http_host), $sst_filename);
$siteBackendUrl = str_replace(array($dt_root, '/index.php'), array('https://' . $http_host, '/'), $st_filename);
defined('SITE_URL') or define('SITE_URL', $siteUrl);
//http://xxxi.com/
//网站管理后台的url
defined('SITE_BACKEND_URL') or define('SITE_BACKEND_URL', $siteBackendUrl);
//http://xxxi.com/admin/
//管理后台路径
defined('SITE_BACKEND_PATH') or define('SITE_BACKEND_PATH', dirname(__FILE__) . '/');
// www/kyii/bd/
//网站路径
defined('SITE_PATH') or define('SITE_PATH', dirname(SITE_BACKEND_PATH) . '/');
// www/kyii/
//加载核心和配置
$yii = dirname(__FILE__) . '/../core/yii.php';
$menu = dirname(__FILE__) . '/protected/config/menu.php';
$main = dirname(__FILE__) . '/protected/config/main.php';
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once $yii;
require_once $menu;
Yii::createWebApplication($main)->run();