diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index efcb3979d..8627552bb 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -75,11 +75,20 @@ EOF; $autoloads = $this->parseAutoloads($packageMap); $vendorPath = $installationManager->getVendorPath(); + $realVendorPath = realpath($vendorPath); + $vendorPathDepth = substr_count(strtr(substr($realVendorPath, strlen(getcwd())), '\\', '/'), '/'); + $appBaseDir = str_repeat('dirname(', $vendorPathDepth).'$baseDir'.str_repeat(')', $vendorPathDepth); + if (isset($autoloads['psr-0'])) { foreach ($autoloads['psr-0'] as $def) { if (!$this->isAbsolutePath($def['path'])) { - $def['path'] = substr($def['path'], strlen($vendorPath)); - $baseDir = '$baseDir . '; + if (strpos($def['path'], $vendorPath) === 0) { + $def['path'] = substr($def['path'], strlen($vendorPath)); + $baseDir = '$baseDir . '; + } else { + $def['path'] = '/'.$def['path']; + $baseDir = $appBaseDir . ' . '; + } } else { $baseDir = ''; } diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index 4ae07c1a4..2acb09d5b 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -44,9 +44,9 @@ class InstallationManager throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath)."); } // convert to relative path - $this->vendorPath = substr($vendorDir, strlen($basePath)+1); + $this->vendorPath = rtrim(substr($vendorDir, strlen($basePath)+1), '/'); } else { - $this->vendorPath = $vendorDir; + $this->vendorPath = rtrim($vendorDir, '/'); } }