diff --git a/composer/Plugin/Scaffold/GenerateAutoloadReferenceFile.php b/composer/Plugin/Scaffold/GenerateAutoloadReferenceFile.php index ede72c47ed..c698a6b8fd 100644 --- a/composer/Plugin/Scaffold/GenerateAutoloadReferenceFile.php +++ b/composer/Plugin/Scaffold/GenerateAutoloadReferenceFile.php @@ -41,10 +41,8 @@ public static function generateAutoload(IOInterface $io, $package_name, $web_roo // Calculate the relative path from the webroot (location of the project // autoload.php) to the vendor directory. $fs = new Filesystem(); - $relative_vendor_path = $fs->findShortestPath($autoload_path->fullPath(), $vendor); - // Simplify the path if it's at the root - $relative_vendor_path = preg_replace('#^\./#', '', $relative_vendor_path); - file_put_contents($autoload_path->fullPath(), static::autoLoadContents($relative_vendor_path)); + $relative_autoload_path = $fs->findShortestPath($autoload_path->fullPath(), "$vendor/autoload.php"); + file_put_contents($autoload_path->fullPath(), static::autoLoadContents($relative_autoload_path)); return new ScaffoldResult($autoload_path, TRUE); } @@ -98,8 +96,8 @@ protected static function autoloadPath($package_name, $web_root) { * @return string * Return the contents for the autoload.php. */ - protected static function autoLoadContents($vendor_path) { - $vendor_path = rtrim($vendor_path, '/'); + protected static function autoLoadContents($relative_autoload_path) { + $relative_autoload_path = preg_replace('#^\./#', '', $relative_autoload_path); return <<