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