本文整理汇总了PHP中Composer\Autoload\ClassLoader::register方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::register方法的具体用法?PHP ClassLoader::register怎么用?PHP ClassLoader::register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Autoload\ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerLoader
private function registerLoader()
{
$package = $this->composer->getPackage();
$generator = $this->composer->getAutoloadGenerator();
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
$packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
$map = $generator->parseAutoloads($packageMap, $package);
$this->loader = $generator->createLoader($map);
$this->loader->register();
}
示例2: load
/**
* Load bundle
*
* @param BundleInterface $bundle
*
* @throws MissingBundleException
*/
public static function load(BundleInterface $bundle)
{
if (is_dir($bundle->getPath())) {
self::$bundlesLoaded[$bundle->getName()] = ['namespace' => $bundle->getNamespace(), 'path' => $bundle->getPath()];
if (!self::$classLoader) {
self::$classLoader = new ClassLoader();
}
self::$classLoader->addPsr4($bundle->getNamespace(), $bundle->getPath());
self::$classLoader->register();
} else {
throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundle->getName()));
}
}
示例3: autoload
/**
* Autoloads all registered extension files with an instance of the app.
*
* @return void
**/
public function autoload($app)
{
$loader = new ClassLoader();
$mapfile = $this->basefolder . '/vendor/composer/autoload_psr4.php';
if (is_readable($mapfile)) {
$map = (require $mapfile);
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$mapfile = $this->basefolder . '/vendor/composer/autoload_classmap.php';
if (is_readable($mapfile)) {
$map = (require $mapfile);
$loader->addClassMap($map);
}
$loader->register();
}
$filepath = $this->basefolder . '/vendor/composer/autoload_files.php';
if (is_readable($filepath)) {
$files = (include $filepath);
foreach ($files as $file) {
try {
if (is_readable($file)) {
require $file;
}
} catch (\Exception $e) {
$this->logInitFailure('Error importing extension class', $file, $e, Logger::ERROR);
}
}
}
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
$classLoader = new ClassLoader();
$classLoader->addPsr4('App\\', __DIR__ . '/Fixtures/src/App');
$classLoader->addPsr4('Test\\', __DIR__ . '/Fixtures/src/Test');
$classLoader->register();
}
示例5: __construct
/** {@inheritdoc} */
public function __construct()
{
parent::__construct();
$this->directory = WT_MODULES_DIR . $this->getName();
// register the namespaces
$loader = new ClassLoader();
$loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyTreeviewPdf\\', $this->directory . '/app');
$loader->register();
}
示例6: registerLoader
/**
* Register classloader for extension
*
* @return \Composer\Autoload\ClassLoader
*/
protected function registerLoader()
{
$classpath = __DIR__;
$nsprefix = __NAMESPACE__ . '\\';
$loader = new ClassLoader();
$loader->addPsr4($nsprefix, $classpath);
$loader->register();
return $loader;
}
示例7: __construct
public function __construct()
{
parent::__construct('fancy_research_links');
$this->directory = WT_MODULES_DIR . $this->getName();
// register the namespace
$loader = new ClassLoader();
$loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyResearchLinks\\', WT_MODULES_DIR . $this->getName() . '/app');
$loader->register();
}
示例8: __construct
public function __construct()
{
parent::__construct('modulename');
$this->directory = WT_MODULES_DIR . $this->getName();
$this->action = Filter::get('mod_action');
// register the namespaces
$loader = new ClassLoader();
$loader->addPsr4('vendor\\WebtreesModules\\modulename\\', $this->directory);
$loader->register();
}
示例9: setUp
protected function setUp()
{
$filesystem = new Filesystem();
$filesystem->remove(__DIR__ . '/Fixtures/tmp');
$filesystem->mirror(__DIR__ . '/Fixtures/template', __DIR__ . '/Fixtures/tmp');
$loader = new ClassLoader();
$loader->addPsr4('Fixtures\\Maba\\Bundle\\', __DIR__ . '/Fixtures/tmp/src');
$loader->addPsr4('Fixtures\\Maba\\', __DIR__ . '/Fixtures/tmp/app');
$loader->register(true);
static::bootKernel();
}
示例10: initialize
public static function initialize(ClassLoader $autoloader = null)
{
if (null === self::$autoloader) {
if (null === $autoloader) {
$autoloader = new ClassLoader();
$autoloader->register();
}
return self::$autoloader = $autoloader;
}
throw new \RuntimeException('Already initialized');
}
示例11: __construct
/** {@inheritdoc} */
public function __construct()
{
parent::__construct('fancy_treeview');
$this->tree = $this->tree();
$this->tree_id = $this->tree->getTreeId();
$this->directory = WT_MODULES_DIR . $this->getName();
$this->action = Filter::get('mod_action');
// register the namespaces
$loader = new ClassLoader();
$loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyTreeview\\', $this->directory . '/src');
$loader->register();
}
示例12: registerClassMaps
public function registerClassMaps($classMap)
{
if (!$classMap) {
return;
}
if (!is_array($classMap)) {
$classMap = [$classMap];
}
$loader = new ClassLoader();
$loader->addClassMap($classMap);
$loader->register(true);
}
示例13: Container
function __construct(array $testSuites = [])
{
$this->container = new Container();
$this->dispatcher = new Dispatcher();
$this->parameters = new ArrayCache();
$this->filesystem = new Filesystem();
$this->configs = new Config();
$this->classLoader = new ClassLoader();
$this->report = new Report();
$this->testSuites = $testSuites;
$this->initialize();
$this->classLoader->register();
static::$instance = $this;
}
示例14: register
/**
* Installs this class loader on the SPL autoload stack.
*
* @param bool $throw If register should throw an exception or not
* @param bool $prepend If register should prepend
*
* @return void
*/
public function register($throw = true, $prepend = false)
{
// register the class loader instance
parent::register($prepend);
// require the files registered with composer (e. g. Swift Mailer)
foreach ($this->directories as $directory) {
if (file_exists($directory . '/composer/autoload_files.php')) {
$includeFiles = (require $directory . '/composer/autoload_files.php');
foreach ($includeFiles as $file) {
require_once $file;
}
}
}
}
示例15: scan
/**
* Scan plugin folder and load plugins
*
* @access public
*/
public function scan()
{
if (file_exists(PLUGINS_DIR)) {
$loader = new ClassLoader();
$loader->addPsr4('Kanboard\\Plugin\\', PLUGINS_DIR);
$loader->register();
$dir = new DirectoryIterator(PLUGINS_DIR);
foreach ($dir as $fileInfo) {
if ($fileInfo->isDir() && substr($fileInfo->getFilename(), 0, 1) !== '.') {
$pluginName = $fileInfo->getFilename();
$this->loadSchema($pluginName);
$this->initializePlugin($this->loadPlugin($pluginName));
}
}
}
}