本文整理匯總了PHP中YiiBase::enableIncludePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP YiiBase::enableIncludePath方法的具體用法?PHP YiiBase::enableIncludePath怎麽用?PHP YiiBase::enableIncludePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類YiiBase
的用法示例。
在下文中一共展示了YiiBase::enableIncludePath方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Initializes initializer.
*/
public function __construct($frameworkScript, $configScript, $webApplicationFactory)
{
defined('YII_DEBUG') or define('YII_DEBUG', true);
require_once $frameworkScript;
// tells Yii to not just include files, but to let other
// autoloaders or the include path try
\YiiBase::$enableIncludePath = false;
// create the application and remember it
$this->yii = $webApplicationFactory::createWebApplication($configScript);
}
示例2: registerAutoloader
public static function registerAutoloader($callback, $append = false)
{
if ($append) {
self::$enableIncludePath = false;
spl_autoload_register($callback);
} else {
spl_autoload_unregister(array('YiiBase', 'autoload'));
spl_autoload_register($callback);
spl_autoload_register(array('YiiBase', 'autoload'));
}
}
示例3: import
public static function import($alias, $forceInclude = false)
{
if (isset(self::$_imports[$alias])) {
//是否已經存在路徑
return self::$_imports[$alias];
}
if (class_exists($alias, false) || interface_exists($alias, false)) {
//類是否已經定義,針對如urlManager這樣的已定義於$_coreClasses[]的類
return self::$_imports[$alias] = $alias;
}
if (($pos = strrpos($alias, '.')) === false) {
// try to autoload the class with an autoloader if $forceInclude is true
if ($forceInclude && (Yii::autoload($alias, true) || class_exists($alias, true))) {
self::$_imports[$alias] = $alias;
}
return $alias;
}
$className = (string) substr($alias, $pos + 1);
$isClass = $className !== '*';
//是否為路徑+類名
if ($isClass && (class_exists($className, false) || interface_exists($className, false))) {
return self::$_imports[$alias] = $className;
}
//獲取真實路徑
if (($path = self::getPathOfAlias($alias)) !== false) {
//是否以*結尾,如application.utils.*
if ($isClass) {
if ($forceInclude) {
if (is_file($path . '.php')) {
require $path . '.php';
} else {
throw new CException(Yii::t('yii', 'Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.', array('{alias}' => $alias)));
}
self::$_imports[$alias] = $className;
} else {
self::$classMap[$className] = $path . '.php';
}
return $className;
} else {
if (self::$_includePaths === null) {
self::$_includePaths = array_unique(explode(PATH_SEPARATOR, get_include_path()));
if (($pos = array_search('.', self::$_includePaths, true)) !== false) {
unset(self::$_includePaths[$pos]);
}
}
array_unshift(self::$_includePaths, $path);
if (self::$enableIncludePath && set_include_path('.' . PATH_SEPARATOR . implode(PATH_SEPARATOR, self::$_includePaths)) === false) {
self::$enableIncludePath = false;
}
return self::$_imports[$alias] = $path;
}
}
}
示例4: yiiVersion
/**
* Initialize Yii and return Yii version
*
* @param bool $refresh
* @return bool|string Yii version or false if Yii is not found
*/
public static function yiiVersion($refresh = false)
{
static $yiiVersion;
if ($yiiVersion !== null && !$refresh) {
return $yiiVersion;
}
$yii_file = self::yiiPath($refresh) . '/framework/YiiBase.php';
if (!file_exists($yii_file)) {
return $yiiVersion = false;
}
require_once $yii_file;
YiiBase::setPathOfAlias('yii_embed', YII_EMBED_PATH . 'app');
YiiBase::import('yii_embed.components.*');
YiiBase::import('yii_embed.models.*');
YiiBase::$enableIncludePath = false;
return $yiiVersion = YiiBase::getVersion();
}
示例5: realpath
<?php
/**
* This is temporary harness to support current code which is tightly coupled to Yii application object.
* It should be called once before each test, and instantiates our minimal CApplication object.
*/
define('ROOT_DIR', realpath(__DIR__ . '/../'));
// Included the Yii
define('YII_PATH', ROOT_DIR . '/vendor/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);
// Set up the shorthands for test app paths
define('APP_ROOT', ROOT_DIR . '/tests/runtime');
define('APP_RUNTIME', APP_ROOT . '/runtime');
// yes, second "runtime" directory inside
define('APP_ASSETS', APP_ROOT . '/assets');
is_dir(APP_RUNTIME) or mkdir(APP_RUNTIME);
is_dir(APP_ASSETS) or mkdir(APP_ASSETS);
// composer autoloader
require_once ROOT_DIR . '/vendor/autoload.php';
require_once YII_PATH . '/YiiBase.php';
require_once ROOT_DIR . '/tests/fakes/Yii.php';
YiiBase::$enableIncludePath = false;
// Instantiated the test app
require_once ROOT_DIR . '/tests/fakes/MinimalApplication.php';
Yii::createApplication('MinimalApplication', array('basePath' => APP_ROOT, 'runtimePath' => APP_RUNTIME, 'aliases' => ['fakes' => ROOT_DIR . '/tests/fakes', 'bootstrap' => ROOT_DIR . '/src'], 'components' => array('assetManager' => array('basePath' => APP_ASSETS), 'bootstrap' => array('class' => 'booster.components.Booster'))));
// fix bug in yii's autoloader (https://github.com/yiisoft/yii/issues/1907)
Yii::import('fakes.*');
// See the `Boostrap.init()` method for explanation why it is needed
define('IS_IN_TESTS', true);