|
|
|
@ -90,13 +90,13 @@ EOF;
|
|
|
|
|
$prefixes = implode(', ', array_map(function ($prefix) {
|
|
|
|
|
return var_export($prefix, true);
|
|
|
|
|
}, array_keys($mainAutoload['psr-0'])));
|
|
|
|
|
$baseDirFromVendorDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
|
|
|
|
|
$baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, getcwd(), true);
|
|
|
|
|
|
|
|
|
|
$targetDirLoader = <<<EOF
|
|
|
|
|
|
|
|
|
|
public static function autoload(\$class)
|
|
|
|
|
{
|
|
|
|
|
\$dir = $baseDirFromVendorDirCode . '/';
|
|
|
|
|
\$dir = $baseDirFromTargetDirCode . '/';
|
|
|
|
|
\$prefixes = array($prefixes);
|
|
|
|
|
foreach (\$prefixes as \$prefix) {
|
|
|
|
|
if (0 !== strpos(\$class, \$prefix)) {
|
|
|
|
@ -136,8 +136,8 @@ EOF;
|
|
|
|
|
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($suffix));
|
|
|
|
|
file_put_contents($vendorPath.'/autoload_real'.$suffix.'.php', $this->getAutoloadRealFile($vendorPathToTargetDirCode, true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $suffix));
|
|
|
|
|
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, $suffix));
|
|
|
|
|
copy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -279,7 +279,7 @@ EOF;
|
|
|
|
|
return $baseDir.var_export($path, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getAutoloadFile($suffix)
|
|
|
|
|
protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -288,20 +288,21 @@ EOF;
|
|
|
|
|
|
|
|
|
|
// autoload.php generated by Composer
|
|
|
|
|
|
|
|
|
|
require_once 'autoload_real$suffix.php';
|
|
|
|
|
require_once $vendorPathToTargetDirCode . '/autoload_real$suffix.php';
|
|
|
|
|
|
|
|
|
|
return ComposerAutoloaderInit$suffix::getLoader();
|
|
|
|
|
|
|
|
|
|
AUTOLOAD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getAutoloadRealFile($vendorPathToTargetDirCode, $usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $suffix)
|
|
|
|
|
protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $suffix)
|
|
|
|
|
{
|
|
|
|
|
// TODO the class ComposerAutoloaderInit should be revert to a closure
|
|
|
|
|
// when APC has been fixed:
|
|
|
|
|
// - https://github.com/composer/composer/issues/959
|
|
|
|
|
// - https://bugs.php.net/bug.php?id=52144
|
|
|
|
|
// - https://bugs.php.net/bug.php?id=61576
|
|
|
|
|
// - https://bugs.php.net/bug.php?id=59298
|
|
|
|
|
|
|
|
|
|
if ($filesCode) {
|
|
|
|
|
$filesCode = "\n".$filesCode;
|
|
|
|
@ -312,7 +313,7 @@ AUTOLOAD;
|
|
|
|
|
|
|
|
|
|
// autoload_real$suffix.php generated by Composer
|
|
|
|
|
if (!class_exists('Composer\\\\Autoload\\\\ClassLoader', false)) {
|
|
|
|
|
require $vendorPathToTargetDirCode . '/ClassLoader.php';
|
|
|
|
|
require __DIR__ . '/ClassLoader.php';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ComposerAutoloaderInit$suffix
|
|
|
|
@ -320,14 +321,13 @@ class ComposerAutoloaderInit$suffix
|
|
|
|
|
public static function getLoader()
|
|
|
|
|
{
|
|
|
|
|
\$loader = new \\Composer\\Autoload\\ClassLoader();
|
|
|
|
|
\$composerDir = $vendorPathToTargetDirCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HEADER;
|
|
|
|
|
|
|
|
|
|
if ($useIncludePath) {
|
|
|
|
|
$file .= <<<'INCLUDE_PATH'
|
|
|
|
|
$includePaths = require $composerDir . '/include_paths.php';
|
|
|
|
|
$includePaths = require __DIR__ . '/include_paths.php';
|
|
|
|
|
array_push($includePaths, get_include_path());
|
|
|
|
|
set_include_path(join(PATH_SEPARATOR, $includePaths));
|
|
|
|
|
|
|
|
|
@ -337,7 +337,7 @@ INCLUDE_PATH;
|
|
|
|
|
|
|
|
|
|
if ($usePSR0) {
|
|
|
|
|
$file .= <<<'PSR0'
|
|
|
|
|
$map = require $composerDir . '/autoload_namespaces.php';
|
|
|
|
|
$map = require __DIR__ . '/autoload_namespaces.php';
|
|
|
|
|
foreach ($map as $namespace => $path) {
|
|
|
|
|
$loader->add($namespace, $path);
|
|
|
|
|
}
|
|
|
|
@ -348,7 +348,7 @@ PSR0;
|
|
|
|
|
|
|
|
|
|
if ($useClassMap) {
|
|
|
|
|
$file .= <<<'CLASSMAP'
|
|
|
|
|
$classMap = require $composerDir . '/autoload_classmap.php';
|
|
|
|
|
$classMap = require __DIR__ . '/autoload_classmap.php';
|
|
|
|
|
if ($classMap) {
|
|
|
|
|
$loader->addClassMap($classMap);
|
|
|
|
|
}
|
|
|
|
|