本文整理汇总了PHP中Yii::createApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::createApplication方法的具体用法?PHP Yii::createApplication怎么用?PHP Yii::createApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::createApplication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize the Plugin Manager callbacks
*/
public static function init()
{
// load language
load_plugin_textdomain('yii_embed', false, basename(YII_EMBED_PATH) . '/languages');
// runs when plugin is activated
register_activation_hook(YII_EMBED_PATH . 'yii_embed.php', 'YiiEmbed::activation');
// runs on plugin deactivation
register_deactivation_hook(YII_EMBED_PATH . 'yii_embed.php', 'YiiEmbed::deactivation');
// setup admin pages
if (is_admin()) {
require_once YII_EMBED_PATH . 'includes/YiiEmbedAdmin.php';
YiiEmbedAdmin::init();
}
// create Yii app
if (YII_EMBED_YII_VERSION) {
require_once YII_EMBED_PATH . 'includes/Yii.php';
// create application
Yii::createApplication('YiiEmbedApplication', YII_EMBED_PATH . 'app/config/main.php');
// add output buffer for clientScript
ob_start('YiiEmbed::renderClientScript');
// handle yii controller
add_filter('template_redirect', 'YiiEmbed::runController');
// register scripts
self::registerScripts();
}
}
示例2: mockApplication
/**
* Populates Yii::app() with a new application
* The application will be destroyed on tearDown() automatically.
* @param array $config The application configuration, if needed
* @param string $appClass name of the application class to create
*/
protected function mockApplication($config = [], $appClass = '\\CWebApplication')
{
if (Yii::app() !== null) {
$this->destroyApplication();
}
Yii::createApplication($appClass, \CMap::mergeArray(['id' => 'testapp', 'basePath' => __DIR__], $config));
}
示例3: getUserAdapter
public function getUserAdapter()
{
Yii::import('wiki.components.auth.*');
if ($this->_userAdapter === null) {
$this->_userAdapter = Yii::createApplication($this->userAdapter);
}
return $this->_userAdapter;
}
示例4: define
use application\modules\message\core\wx\Factory;
use application\modules\message\core\wx\WxApi;
use application\modules\user\model\UserBinding;
// 程序根目录路径
define('PATH_ROOT', dirname(__FILE__) . '/../../');
$defines = PATH_ROOT . '/system/defines.php';
define('TIMESTAMP', time());
define('YII_DEBUG', true);
define('CALLBACK', true);
$yii = PATH_ROOT . '/library/yii.php';
$mainConfig = (require_once PATH_ROOT . '/system/config/common.php');
require_once $defines;
require_once $yii;
require_once '../login.php';
Yii::setPathOfAlias('application', PATH_ROOT . DIRECTORY_SEPARATOR . 'system');
Yii::createApplication('application\\core\\components\\Application', $mainConfig);
// 接收的参数
$msgSignature = rawurldecode(Env::getRequest('msgSignature'));
$timestamp = rawurldecode(Env::getRequest('timestamp'));
$aeskey = WxApi::getInstance()->getAeskey();
$echoStr = rawurldecode(Env::getRequest('echoStr'));
if (strcmp($msgSignature, md5($aeskey . $timestamp)) != 0) {
Env::iExit('access denied');
}
if (!empty($echoStr)) {
WxApi::getInstance()->resetCorp();
Env::iExit($echoStr);
}
// 接收信息处理
$result = trim(file_get_contents("php://input"), " \t\n\r");
// 解析
示例5: dirname
<?php
// change the following paths if necessary
$yii = dirname(__FILE__) . '/../../../protected/extensions/yii-environment/Environment.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', 0);
require_once $yii;
require dirname(__FILE__) . '/../../../protected/components/UcenterApplication.php';
Yii::createApplication('UcenterApplication', $config)->run();
示例6: defined
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
// Setting application base paths for configuration and framework
$yiiFramework = dirname(__FILE__) . '/vendor/framework/yii.php';
$globalConfiguration = dirname(__FILE__) . '/app/app.php';
$globalApplication = dirname(__FILE__) . '/protected/application/Application.php';
// Require yii framework to start the application
// Require configuration and base web application
require_once $globalConfiguration;
require_once $yiiFramework;
require_once $globalApplication;
// Run the web application
Yii::createApplication('Application', $globalConfiguration)->run();
Yii::import('application.vendors.*');
示例7:
* feasible for technical reasons, the Appropriate Legal Notices must display the words
* "Copyright Zurmo Inc. 2015. All rights reserved".
********************************************************************************/
require_once 'version.php';
if (is_file('commercialVersion.php')) {
require_once 'commercialVersion.php';
}
require_once 'roots.php';
// Debug is used per instance.
if (is_file(INSTANCE_ROOT . '/protected/config/debug.php')) {
$debug = INSTANCE_ROOT . '/protected/config/debug.php';
} else {
$debug = INSTANCE_ROOT . '/protected/config/debugDIST.php';
}
// Runtime path is used per instance.
$runtimePath = INSTANCE_ROOT . '/protected/runtime';
// The config is used per instance.
$config = INSTANCE_ROOT . '/protected/config/main.php';
// Yii is used from the common source.
$yii = COMMON_ROOT . '/../yii/framework/yii.php';
// WebApplication is used from the common source.
$webApplication = COMMON_ROOT . '/protected/core/components/WebApplication.php';
require_once $debug;
require_once $yii;
require_once $webApplication;
$webApplication = Yii::createApplication('WebApplication', $config);
if (file_exists($runtimePath)) {
$webApplication->setRuntimePath($runtimePath);
}
$webApplication->run();
exit;
示例8:
*
* You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
* Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
*
* The interactive user interfaces in original and modified versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the Zurmo
* logo and Zurmo copyright notice. If the display of the logo is not reasonably
* feasible for technical reasons, the Appropriate Legal Notices must display the words
* "Copyright Zurmo Inc. 2013. All rights reserved".
********************************************************************************/
require_once 'testRoots.php';
require_once 'TestConfigFileUtils.php';
TestConfigFileUtils::configureConfigFiles();
$debug = INSTANCE_ROOT . '/protected/config/debugTest.php';
$yiit = COMMON_ROOT . "/../yii/framework/yiit.php";
$config = INSTANCE_ROOT . "/protected/config/test.php";
require_once COMMON_ROOT . "/version.php";
require_once COMMON_ROOT . "/protected/modules/install/utils/InstallUtil.php";
require_once COMMON_ROOT . "/protected/core/utils/ZurmoPasswordSecurityUtil.php";
InstallUtil::setZurmoTokenAndWriteToPerInstanceFile(INSTANCE_ROOT, 'perInstanceTest.php');
ZurmoPasswordSecurityUtil::setPasswordSaltAndWriteToPerInstanceFile(INSTANCE_ROOT, 'perInstanceTest.php');
require_once $debug;
require_once $yiit;
require_once COMMON_ROOT . '/protected/core/components/WebApplication.php';
require_once COMMON_ROOT . '/protected/tests/WebTestApplication.php';
Yii::createApplication('WebTestApplication', $config);
示例9: define
if (isset($_GET['init']) && $_GET['init']) {
// 初始化ibos核心
// 定义驱动引擎
define('ENGINE', 'LOCAL');
// TODO,上线记得删除此行
define('YII_DEBUG', FALSE);
$yii = PATH_ROOT . '/library/yii.php';
$ibosApplication = PATH_ROOT . '/system/core/components/ICApplication.php';
require_once $yii;
require_once $ibosApplication;
$commonConfig = (require CONFIG_PATH . 'common.php');
// 由于模块安装之间的依赖性,需要用到dashboard的一些组件,所以得加载进来
$dashboardImport = array('application.modules.dashboard.model.*', 'application.modules.dashboard.utils.*');
$commonConfig['import'] = array_merge($commonConfig['import'], $dashboardImport);
unset($commonConfig['preload']);
Yii::createApplication('ICApplication', $commonConfig);
}
$updataLockFile = PATH_ROOT . './data/updateSQL.lock';
// 是否已升级过
if (file_exists($updataLockFile)) {
$errorMsg = $lang['UpdateSQL locked'] . str_replace(PATH_ROOT, '', $updataLockFile);
include 'errorInfo.php';
exit;
}
if (!isset($_GET['step'])) {
$step = 'prepare';
} else {
$step = $_GET['step'];
}
$ibos1ConfigFile = CONFIG_PATH_IBOS1 . 'config_global.php';
$ibos2ConfigFile = CONFIG_PATH . 'config.php';
示例10: onBeginRequest
class StandaloneApplication extends CWebApplication
{
public function onBeginRequest($event)
{
return;
}
public function onEndRequest($event)
{
return;
}
public function processRequest()
{
return;
}
}
Yii::createApplication('StandaloneApplication', $root . $conf['config'])->run();
Yii::app()->user;
// the only thing we need from yii
// we need to remove the autoloader of yii otherwise the kcfinder autoloader doesn't work
spl_autoload_unregister(array('YiiBase', 'autoload'));
function CheckAuthentication()
{
return Yii::app()->user->id > 0;
}
/** This file is part of KCFinder project
*
* @desc Base configuration file
* @package KCFinder
* @version 3.12
* @author Pavel Tzonkov <sunhater@sunhater.com>
* @copyright 2010-2014 KCFinder Project
示例11: createConsoleApplication
public static function createConsoleApplication($config=null)
{
return Yii::createApplication('EConsoleApplication',$config);
}
示例12:
<?php
/**
* Entry point script for backend.
*
* @author: antonio ramirez <antonio@clevertech.biz>
* @author: mark safronov <hijarian@gmail.com>
*/
# Loading project default init code for all entry points.
require __DIR__ . '/../../common/bootstrap.php';
# Setting up the frontend-specific aliases
Yii::setPathOfAlias('backend', ROOT_DIR . '/backend');
Yii::setPathOfAlias('www', ROOT_DIR . '/backend/www');
# As we are using BootstrapFilter to include Booster, we have to define 'bootstrap' alias ourselves
# Note that we are binding to Composer-installed version of YiiBooster
Yii::setPathOfAlias('bootstrap', ROOT_DIR . '/vendor/clevertech/yii-booster/src');
Yii::setPathOfAlias('yiistrap', ROOT_DIR . '/vendor/yiistrap');
# We use our custom-made WebApplication component as base class for backend app.
require_once ROOT_DIR . '/backend/components/BackendWebApplication.php';
# For obvious reasons, backend entry point is constructed of specialised WebApplication and config
Yii::createApplication('BackendWebApplication', ROOT_DIR . '/backend/config/main.php')->run();
示例13: doRequest
/**
*
* @param \Symfony\Component\BrowserKit\Request $request
*
* @return \Symfony\Component\BrowserKit\Response
*/
public function doRequest($request)
{
$this->headers = array();
$_COOKIE = array_merge($_COOKIE, $request->getCookies());
$_SERVER = array_merge($_SERVER, $request->getServer());
$_FILES = $this->remapFiles($request->getFiles());
$_REQUEST = $this->remapRequestParameters($request->getParameters());
$_POST = $_GET = array();
if (strtoupper($request->getMethod()) == 'GET') {
$_GET = $_REQUEST;
} else {
$_POST = $_REQUEST;
}
// Parse url parts
$uriPath = trim(parse_url($request->getUri(), PHP_URL_PATH), '/');
$uriQuery = ltrim(parse_url($request->getUri(), PHP_URL_QUERY), '?');
$scriptName = trim(parse_url($this->url, PHP_URL_PATH), '/');
if (!empty($uriQuery)) {
$uriPath .= "?{$uriQuery}";
parse_str($uriQuery, $params);
foreach ($params as $k => $v) {
$_GET[$k] = $v;
}
}
// Add script name to request if none
if (strpos($uriPath, $scriptName) === false) {
$uriPath = "/{$scriptName}/{$uriPath}";
}
// Add forward slash if not exists
if (strpos($uriPath, '/') !== 0) {
$uriPath = "/{$uriPath}";
}
$_SERVER['REQUEST_METHOD'] = strtoupper($request->getMethod());
$_SERVER['REQUEST_URI'] = $uriPath;
/**
* Hack to be sure that CHttpRequest will resolve route correctly
*/
$_SERVER['SCRIPT_NAME'] = "/{$scriptName}";
$_SERVER['SCRIPT_FILENAME'] = $this->appPath;
ob_start();
\Yii::setApplication(null);
\Yii::createApplication($this->appSettings['class'], $this->appSettings['config']);
$app = \Yii::app();
// disabling logging. Logs slow down test execution
if ($app->hasComponent('log')) {
foreach ($app->getComponent('log')->routes as $route) {
$route->enabled = false;
}
}
if ($app->hasComponent('session')) {
// disable regenerate id in session
$app->setComponent('session', Stub::make('CHttpSession', ['regenerateID' => false]));
}
$app->onEndRequest->add([$this, 'setHeaders']);
$app->run();
if ($app->hasComponent('db')) {
// close connection
$app->getDb()->setActive(false);
// cleanup metadata cache
$property = new \ReflectionProperty('CActiveRecord', '_md');
$property->setAccessible(true);
$property->setValue([]);
}
$content = ob_get_clean();
$headers = $this->getHeaders();
$statusCode = 200;
foreach ($headers as $header => $val) {
if ($header == 'Location') {
$statusCode = 302;
}
}
$response = new Response($content, $statusCode, $this->getHeaders());
return $response;
}
示例14: defined
<?php
# This is the entry point for console application.
#
# We do not use the built-in `yiic.php` because of our own class including order.
require_once __DIR__ . '/../common/bootstrap.php';
# Our own boilerplate for ConsoleApplication
require_once ROOT_DIR . '/console/components/ConsoleApplication.php';
require_once ROOT_DIR . '/vendor/clio/src/Clio/Console.php';
Yii::setPathOfAlias('yiistrap', ROOT_DIR . '/vendor/yiistrap');
Yii::setPathOfAlias('backend', ROOT_DIR . '/backend');
# fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
/** @var ConsoleApplication $app */
$app = Yii::createApplication('ConsoleApplication', ROOT_DIR . '/console/config/main.php');
$app->commandRunner->addCommands(YII_PATH . '/cli/commands');
$app->commandRunner->addCommands(@getenv('YII_CONSOLE_COMMANDS'));
$app->run();
示例15: switch
switch ($error['type']) {
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
$isError = true;
break;
}
}
if ($isError) {
date_default_timezone_set('Europe/Ljubljana');
if (defined("THREAD") && defined("THREAD_TYPE")) {
print date("d.m.Y H:i:s") . " :: " . THREAD_TYPE . " Thread :: " . str_pad(THREAD, 3, "0", STR_PAD_LEFT) . " :: Script execution halted ({$error['message']})\n";
} else {
print date("d.m.Y H:i:s") . " :: Script execution halted ({$error['message']})\n";
}
if (defined("THREAD") && defined("THREAD_TYPE")) {
require_once dirname(__FILE__) . '/../common/lib/Net/Gearman/Client.php';
print date("d.m.Y H:i:s") . " :: " . THREAD_TYPE . " Thread :: " . str_pad(THREAD, 3, "0", STR_PAD_LEFT) . " :: Starting workers restart...\n";
$set = new Net_Gearman_Set();
$task = new Net_Gearman_Task("Worker_Restarter", 1);
$task->type = Net_Gearman_Task::JOB_BACKGROUND;
$set->addTask($task);
$client = new Net_Gearman_Client(array('127.0.0.1:4730'));
$client->runSet($set);
}
}
}
register_shutdown_function('thread_shutdown');
Yii::createApplication("WorkerApplication", $config)->run();