本文整理汇总了PHP中ClassLoader::addDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::addDirectory方法的具体用法?PHP ClassLoader::addDirectory怎么用?PHP ClassLoader::addDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::addDirectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realpath
<?php
error_reporting(-1);
date_default_timezone_set('UTC');
define('PATH_ROOT', realpath(dirname(__DIR__)));
define('PATH_SYSTEM', PATH_ROOT . '/vendor/wb-crowdfusion/crowdfusion/system');
if (!file_exists(PATH_ROOT . '/composer.lock')) {
die("Dependencies must be installed using composer:\n\nphp composer.phar install\n\n" . "See http://getcomposer.org for help with installing composer\n");
}
include PATH_ROOT . '/vendor/autoload.php';
require PATH_SYSTEM . '/context/ApplicationContext.php';
$loader = new ClassLoader();
$loader->addDirectory(PATH_SYSTEM . '/core/classes/');
$loader->addDirectory(PATH_ROOT . '/classes/');
$loader->addClassDirectory(PATH_ROOT . '/tests/');
示例2: loadPluginDirectory
protected function loadPluginDirectory(Configuration $configurationLoader, SplFileInfo $dir, $checkStatus = true)
{
$pluginName = $dir->getBasename();
$realPath = $dir->getRealPath();
if ($checkStatus) {
// read .plugin file for plugin info
$plugin = $this->getPluginStatus($pluginName);
if (is_null($plugin) || $plugin['enabled'] !== true) {
return null;
}
// no plugin file, plugin is not installed
if ($plugin['priority'] > $this->lastPriority) {
$this->lastPriority = $plugin['priority'];
}
} else {
$plugin = array("enabled" => true, "priority" => ++$this->lastPriority);
}
$plugin = array_merge(array('directory' => $realPath), $plugin);
// add classes to classpath
ClassLoader::addDirectory($realPath, $this->autoloadExtension, $this->bypassDirectoriesForAutoload);
// ADD PSR-0/PEAR Compliant Classes
if (file_exists($realPath . DIRECTORY_SEPARATOR . 'autoload_psr-0.php')) {
$psrDirectories = (include $realPath . DIRECTORY_SEPARATOR . 'autoload_psr-0.php');
foreach ($psrDirectories as $psrDir) {
ClassLoader::addClassDirectory($realPath . DIRECTORY_SEPARATOR . $psrDir);
}
}
if (file_exists($realPath . DIRECTORY_SEPARATOR . 'autoload_pear.php')) {
$pearDirectories = (include $realPath . DIRECTORY_SEPARATOR . 'autoload_pear.php');
foreach ($pearDirectories as $pearPrefix => $pearDir) {
ClassLoader::addClassDirectory($realPath . DIRECTORY_SEPARATOR . $pearDir, $this->autoloadExtension, false, $pearPrefix);
}
}
$plugin['id'] = $pluginName;
if (!empty($this->bootstrapFile) && file_exists($realPath . DIRECTORY_SEPARATOR . $this->bootstrapFile)) {
$plugin['bootstrapped'] = true;
}
// locate plugin context
if (!empty($this->pluginContextFile) && ($contextXML = $realPath . DIRECTORY_SEPARATOR . $this->pluginContextFile) && file_exists($contextXML)) {
$plugin['context'] = $this->loadContextFile($configurationLoader, $contextXML);
} else {
if (file_exists($realPath . DIRECTORY_SEPARATOR . $this->sharedContextFile)) {
$plugin['context'] = $this->loadContextFile($configurationLoader, $realPath . DIRECTORY_SEPARATOR . $this->sharedContextFile);
}
}
return $plugin;
}