本文整理匯總了PHP中Composer\Autoload\ClassLoader::setUseIncludePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassLoader::setUseIncludePath方法的具體用法?PHP ClassLoader::setUseIncludePath怎麽用?PHP ClassLoader::setUseIncludePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Autoload\ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::setUseIncludePath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerDefaultAutoloading
/**
* Registers default autoloading for the Extension.
*
* @return \Composer\Autoload\ClassLoader
*/
public function registerDefaultAutoloading()
{
$loader = new ClassLoader();
$loader->add($this->namespace, $this->path . '/src');
$loader->register();
$loader->setUseIncludePath(true);
return $this->autoloaders[] = $loader;
}
示例2: loadModule
protected function loadModule($modCfgArray, $modIdx)
{
$cfg = new Config($modCfgArray['default']);
$ns = $cfg->get('namespace');
// If this class can't be loaded, enable the autoload using the composer class loader.
if (!empty($ns)) {
// Full directory of the module to be initialized.
$dir = $cfg->get('directory');
$parentDir = $this->config->get('directory');
$parentModulesDir = $this->config->get('modulesDir');
if (preg_match('/^\\//', $dir) > 0) {
} else {
if (preg_match('/^\\//', $parentModulesDir) > 0) {
$dir = $parentModulesDir . DIRECTORY_SEPARATOR . $dir;
} else {
$dir = $parentDir . DIRECTORY_SEPARATOR . $parentModulesDir . DIRECTORY_SEPARATOR . $dir;
}
}
$dirReal = realpath($dir) . DIRECTORY_SEPARATOR;
if (!$dirReal) {
throw new \Exception("The directory {$dir} of the child module does not exists or is not readable.");
}
// Override the current module 'directory' value
$cfg->set('directory', $dir);
// Add the namespacec to the composer ClassLoader
$loader = new ClassLoader();
$loader->add($ns, $dir);
$loader->register();
$loader->setUseIncludePath(true);
}
if ($cn = $cfg->get('moduleClassName')) {
$mClass = $ns . '\\' . $cn;
} else {
// Use the default moduleClassName. See the top of this file.
$mClass = $this->config->get('moduleClassName');
}
// Add others options sets, if provided
foreach ($modCfgArray as $k => $optSet) {
if ($k == 'default') {
continue;
}
$cfg->set($optSet, null, $k);
}
// Instance the module.
$mod = new $mClass($cfg, $this, $this->injections);
return $this->children[$modIdx] = $mod;
}
示例3: registerAutoloading
/**
* Register the class autoloading.
*
* @return void
*/
protected function registerAutoloading()
{
// Instantiate the class loader.
$loader = new ClassLoader();
// Add the extension namespace and path.
$loader->add($this->namespace, $this->path . '/src');
// Register the loader.
$loader->register();
// Use the path for includes.
$loader->setUseIncludePath(true);
}