当前位置: 首页>>代码示例>>PHP>>正文


PHP Composer::getAutoloadGenerator方法代码示例

本文整理汇总了PHP中Composer\Composer::getAutoloadGenerator方法的典型用法代码示例。如果您正苦于以下问题:PHP Composer::getAutoloadGenerator方法的具体用法?PHP Composer::getAutoloadGenerator怎么用?PHP Composer::getAutoloadGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Composer的用法示例。


在下文中一共展示了Composer::getAutoloadGenerator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
 }
开发者ID:helhum,项目名称:typo3-console-plugin,代码行数:10,代码来源:ScriptDispatcher.php

示例2: dumpAutoloads

 /**
  * @param bool $optimize
  * @param bool $reload
  */
 protected function dumpAutoloads($optimize = true, $reload = false)
 {
     if ($reload) {
         $this->composer = Factory::create($this->io, null, $this->disablePluginsByDefault);
     }
     $config = $this->composer->getConfig();
     $generator = $this->composer->getAutoloadGenerator();
     $installationManager = $this->composer->getInstallationManager();
     $localRepository = $this->composer->getRepositoryManager()->getLocalRepository();
     $package = $this->composer->getPackage();
     $generator->dump($config, $localRepository, $package, $installationManager, 'composer', $optimize);
     $this->info('Composer DumpAutoloads Completed!');
 }
开发者ID:notadd,项目名称:framework,代码行数:17,代码来源:Command.php

示例3: initGingerBackend

 protected function initGingerBackend()
 {
     $extra = $this->composer->getPackage()->getExtra();
     if (!isset($extra['bootstrap'])) {
         throw new Exception\RuntimeException('No Bootstrap defined. Please add the -bootstrap- definition to the -extra- property of the Ginger WfMS composer.json');
     }
     $bootstrapClass = $extra['bootstrap'];
     if (!class_exists($bootstrapClass)) {
         $this->composer->getAutoloadGenerator()->createLoader($this->composer->getPackage()->getAutoload())->register();
     }
     $bootstrapClass::init();
     $this->serviceManager = $bootstrapClass::getServiceManager();
 }
开发者ID:gingerwfms,项目名称:ginger-plugin-installer,代码行数:13,代码来源:GingerInstaller.php

示例4: activate

 public function activate(Composer $composer, IOInterface $io)
 {
     // if the autoload.php was already generated use this for autoloading
     // else register a new autoloader
     $file = $composer->getConfig()->get('vendor-dir') . '/autoload.php';
     if (is_file($file)) {
         include $file;
     } else {
         // register class loader to load amun classes
         $generator = $composer->getAutoloadGenerator();
         $classLoader = $generator->createLoader($composer->getPackage()->getAutoload());
         $classLoader->register();
     }
     // register installer
     $installer = new ServiceInstaller($io, $composer);
     $composer->getInstallationManager()->addInstaller($installer);
 }
开发者ID:visapi,项目名称:amun,代码行数:17,代码来源:ServicePlugin.php

示例5: create

 /**
  * Create Installer
  *
  * @param  IOInterface $io
  * @param  Composer    $composer
  * @return Installer
  */
 public static function create(IOInterface $io, Composer $composer)
 {
     return new static($io, $composer->getConfig(), $composer->getPackage(), $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $composer->getEventDispatcher(), $composer->getAutoloadGenerator());
 }
开发者ID:Flesh192,项目名称:magento,代码行数:11,代码来源:Installer.php

示例6: createInstaller

 /**
  * Create an Installer instance.
  *
  * Private static factory, to allow slip-streaming in a mock as needed for
  * testing.
  */
 private static function createInstaller(Composer $composer, IOInterface $io, PackageInterface $package)
 {
     $eventDispatcher = new EventDispatcher($composer, $io);
     return new ComposerInstaller($io, $composer->getConfig(), $package, $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), $composer->getInstallationManager(), $eventDispatcher, $composer->getAutoloadGenerator());
 }
开发者ID:zendframework,项目名称:zend-skeleton-installer,代码行数:11,代码来源:OptionalPackagesInstaller.php

示例7: generateAliasMap

    /**
     * @return bool
     * @throws \Exception
     */
    public function generateAliasMap()
    {
        $config = $this->composer->getConfig();
        $filesystem = new Filesystem();
        $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
        $basePath = $this->extractBasePath($config);
        $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
        $targetDir = $vendorPath . '/composer';
        $filesystem->ensureDirectoryExists($targetDir);
        $mainPackage = $this->composer->getPackage();
        $autoLoadGenerator = $this->composer->getAutoloadGenerator();
        $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
        $packageMap = $autoLoadGenerator->buildPackageMap($this->composer->getInstallationManager(), $mainPackage, $localRepo->getCanonicalPackages());
        $aliasToClassNameMapping = array();
        $classNameToAliasMapping = array();
        $classAliasMappingFound = false;
        foreach ($packageMap as $item) {
            /** @var PackageInterface $package */
            list($package, $installPath) = $item;
            $aliasLoaderConfig = new \TYPO3\ClassAliasLoader\Config($package, $this->IO);
            if ($aliasLoaderConfig->get('class-alias-maps') !== null) {
                if (!is_array($aliasLoaderConfig->get('class-alias-maps'))) {
                    throw new \Exception('Configuration option "class-alias-maps" must be an array');
                }
                foreach ($aliasLoaderConfig->get('class-alias-maps') as $mapFile) {
                    $mapFilePath = ($installPath ?: $basePath) . '/' . $filesystem->normalizePath($mapFile);
                    if (!is_file($mapFilePath)) {
                        $this->IO->writeError(sprintf('The class alias map file "%s" configured in package "%s" was not found!', $mapFile, $package->getName()));
                    } else {
                        $packageAliasMap = (require $mapFilePath);
                        if (!is_array($packageAliasMap)) {
                            throw new \Exception('Class alias map files must return an array', 1422625075);
                        }
                        if (!empty($packageAliasMap)) {
                            $classAliasMappingFound = true;
                        }
                        foreach ($packageAliasMap as $aliasClassName => $className) {
                            $lowerCasedAliasClassName = strtolower($aliasClassName);
                            $aliasToClassNameMapping[$lowerCasedAliasClassName] = $className;
                            $classNameToAliasMapping[$className][$lowerCasedAliasClassName] = $lowerCasedAliasClassName;
                        }
                    }
                }
            }
        }
        $mainPackageAliasLoaderConfig = new \TYPO3\ClassAliasLoader\Config($mainPackage);
        $alwaysAddAliasLoader = $mainPackageAliasLoaderConfig->get('always-add-alias-loader');
        $caseSensitiveClassLoading = $mainPackageAliasLoaderConfig->get('autoload-case-sensitivity');
        if (!$alwaysAddAliasLoader && !$classAliasMappingFound && $caseSensitiveClassLoading) {
            // No mapping found in any package and no insensitive class loading active. We return early and skip rewriting
            // Unless user configured alias loader to be always added
            return false;
        }
        $caseSensitiveClassLoadingString = $caseSensitiveClassLoading ? 'true' : 'false';
        $this->IO->write('<info>Generating ' . ($classAliasMappingFound ? ' ' : 'empty ') . 'class alias map file</info>');
        $this->generateAliasMapFile($aliasToClassNameMapping, $classNameToAliasMapping, $targetDir);
        $suffix = null;
        if (!$config->get('autoloader-suffix') && is_readable($vendorPath . '/autoload.php')) {
            $content = file_get_contents($vendorPath . '/autoload.php');
            if (preg_match('{ComposerAutoloaderInit([^:\\s]+)::}', $content, $match)) {
                $suffix = $match[1];
            }
        }
        if (!$suffix) {
            $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
        }
        $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
        $aliasLoaderInitClassContent = <<<EOF
<?php

// autoload_alias_loader_real.php @generated by typo3/class-alias-loader

class ClassAliasLoaderInit{$suffix} {

    private static \$loader;

    public static function initializeClassAliasLoader(\$composerClassLoader) {
        if (null !== self::\$loader) {
            return self::\$loader;
        }
        self::\$loader = \$composerClassLoader;

        \$classAliasMap = require __DIR__ . '/autoload_classaliasmap.php';
        \$classAliasLoader = new TYPO3\\ClassAliasLoader\\ClassAliasLoader(\$composerClassLoader);
        \$classAliasLoader->setAliasMap(\$classAliasMap);
        \$classAliasLoader->setCaseSensitiveClassLoading({$caseSensitiveClassLoadingString});
        \$classAliasLoader->register({$prependAutoloader});

        TYPO3\\ClassAliasLoader\\ClassAliasMap::setClassAliasLoader(\$classAliasLoader);

        return self::\$loader;
    }
}

EOF;
        file_put_contents($targetDir . '/autoload_alias_loader_real.php', $aliasLoaderInitClassContent);
//.........这里部分代码省略.........
开发者ID:graurus,项目名称:testgit_t37,代码行数:101,代码来源:ClassAliasMapGenerator.php

示例8: reDumpAutoloader

 /**
  * @param Composer $composer
  *
  * @return void
  */
 private static function reDumpAutoloader(Composer $composer)
 {
     $composer->getAutoloadGenerator()->dump($composer->getConfig(), $composer->getRepositoryManager()->getLocalRepository(), $composer->getPackage(), $composer->getInstallationManager(), 'composer', true);
 }
开发者ID:WyriHaximus,项目名称:PackageVersions,代码行数:9,代码来源:Installer.php


注:本文中的Composer\Composer::getAutoloadGenerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。