當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Yii::createWebApplication方法代碼示例

本文整理匯總了PHP中Yii::createWebApplication方法的典型用法代碼示例。如果您正苦於以下問題:PHP Yii::createWebApplication方法的具體用法?PHP Yii::createWebApplication怎麽用?PHP Yii::createWebApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Yii的用法示例。


在下文中一共展示了Yii::createWebApplication方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 /**
  * @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;
 }
開發者ID:2amigos,項目名稱:yiinitializr,代碼行數:32,代碼來源:Initializer.php

示例2: setUp

 /**
  * 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();
 }
開發者ID:janym,項目名稱:angular-yii,代碼行數:34,代碼來源:EActiveRecordRelationBehaviorTest.php

示例3: actionClearFrontend

 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');
 }
開發者ID:lhfcainiao,項目名稱:basic,代碼行數:9,代碼來源:SettingsController.php

示例4: init

 /**
  * 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();
     }
 }
開發者ID:jralison,項目名稱:chrono,代碼行數:16,代碼來源:index.php

示例5: run

    /**
     * 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();
    }
開發者ID:upmunspel,項目名稱:abiturient,代碼行數:47,代碼來源:ShellCommand.php

示例6: __construct

 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();
 }
開發者ID:mgcxy,項目名稱:yiiSwoole,代碼行數:43,代碼來源:server.php

示例7: setUp

 /**
  * 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();
 }
開發者ID:kostya1017,項目名稱:our,代碼行數:26,代碼來源:EActiveRecordRelationBehaviorTest.php

示例8: dirname

<?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();
開發者ID:alexey-tichonoff,項目名稱:accounting-system,代碼行數:11,代碼來源:index.php

示例9: dirname

<?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();
開發者ID:laiello,項目名稱:what-i-need,代碼行數:18,代碼來源:index.php

示例10: date_default_timezone_set

<?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();
開發者ID:RonLab1987,項目名稱:43berega,代碼行數:29,代碼來源:index.php

示例11: define

<?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();
開發者ID:rizaldi-github,項目名稱:yii-menu-module,代碼行數:24,代碼來源:index.php

示例12:

<?php

require_once 'define.php';
$config = ROOT_PATH . '/protected/config/fontend.php';
// create a Web application instance and run
Yii::createWebApplication($config)->runEnd('fontend');
開發者ID:haanhman,項目名稱:rateapp,代碼行數:6,代碼來源:index.php

示例13: header

<?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();
開發者ID:kosenka,項目名稱:yboard,代碼行數:22,代碼來源:index.php

示例14: error_reporting

<?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');
開發者ID:handita,項目名稱:ServicesSPPKS,代碼行數:6,代碼來源:bootstrap.php

示例15: dirname

//директория ядра фреймворка
$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();
開發者ID:DmitrySM,項目名稱:PHPJobOffer,代碼行數:30,代碼來源:index.php


注:本文中的Yii::createWebApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。