本文整理汇总了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);