mirror of
https://github.com/composer/composer
synced 2025-05-10 09:02:59 +00:00
Allow loading of multiple composer autoloaders concurrently, fixes #1248
This commit is contained in:
parent
c0e75e5d24
commit
487e66d0a9
12 changed files with 112 additions and 52 deletions
|
@ -158,13 +158,17 @@ EOF;
|
|||
$filesCode .= ' require '.$this->getPathCode($filesystem, $relVendorPath, $vendorPath, $functionFile).";\n";
|
||||
}
|
||||
|
||||
if (!$suffix) {
|
||||
$suffix = md5(uniqid('', true));
|
||||
}
|
||||
|
||||
file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile);
|
||||
file_put_contents($targetDir.'/autoload_classmap.php', $classmapFile);
|
||||
if ($includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $relVendorPath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
|
||||
file_put_contents($targetDir.'/include_paths.php', $includePathFile);
|
||||
}
|
||||
file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
|
||||
file_put_contents($targetDir.'/autoload_real'.$suffix.'.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix));
|
||||
file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix));
|
||||
copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
|
||||
}
|
||||
|
||||
|
@ -313,7 +317,7 @@ EOF;
|
|||
|
||||
// autoload.php generated by Composer
|
||||
|
||||
require_once $vendorPathToTargetDirCode . '/autoload_real$suffix.php';
|
||||
require_once $vendorPathToTargetDirCode . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit$suffix::getLoader();
|
||||
|
||||
|
@ -336,21 +340,29 @@ AUTOLOAD;
|
|||
$file = <<<HEADER
|
||||
<?php
|
||||
|
||||
// autoload_real$suffix.php generated by Composer
|
||||
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
// autoload_real.php generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit$suffix
|
||||
{
|
||||
private static \$loader;
|
||||
|
||||
public static function loadClassLoader(\$class)
|
||||
{
|
||||
if ('Composer\\Autoload\\ClassLoader' === \$class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== static::\$loader) {
|
||||
return static::\$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
|
||||
static::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
|
||||
|
||||
\$vendorDir = $vendorPathCode;
|
||||
\$baseDir = $appBaseDirCode;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue