diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index fce0756c3..f7abfe1c2 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -46,12 +46,13 @@ class AutoloadGenerator $targetDir = $vendorPath.'/'.$targetDir; $filesystem->ensureDirectoryExists($targetDir); - $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath, true); + $cwd = getcwd(); + $relVendorPath = $filesystem->findShortestPath($cwd, $vendorPath, true); $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode); $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true); - $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true); + $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $cwd, true); $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode); $namespacesFile = <<findShortestPathCode($targetDir, getcwd(), true); + $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $cwd, true); $targetDirLoader = << $path) { if ('' === $namespace || 0 === strpos($class, $namespace)) { - $path = '/'.$filesystem->findShortestPath(getcwd(), $path, true); + $path = '/'.$filesystem->findShortestPath($cwd, $path, true); if (!isset($classMap[$class])) { $classMap[$class] = '$baseDir . '.var_export($path, true).",\n"; } @@ -158,8 +159,12 @@ EOF; $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap'])); foreach ($autoloads['classmap'] as $dir) { foreach (ClassMapGenerator::createMap($dir) as $class => $path) { - $path = '/'.$filesystem->findShortestPath(getcwd(), $path, true); - $classMap[$class] = '$baseDir . '.var_export($path, true).",\n"; + $path = $filesystem->findShortestPath($cwd, $path, true); + if ($filesystem->isAbsolutePath($path)) { + $classMap[$class] = var_export($path, true).",\n"; + } else { + $classMap[$class] = '$baseDir . '.var_export('/'.$path, true).",\n"; + } } }