本文整理汇总了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();
}
示例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!');
}
示例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();
}
示例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);
}
示例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());
}
示例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());
}
示例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);
//.........这里部分代码省略.........
示例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);
}