diff --git a/README.md b/README.md index e93323764..536632996 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ themselves. To create libraries/packages please read the [guidelines](http://pac } } ``` - + 3. Run Composer: `php composer.phar install` 4. Browse for more packages on [Packagist](http://packagist.org). @@ -51,7 +51,7 @@ in a system wide way. Configuration ------------- -Additional options for composer can be configured in `composer.json` by using the `config` section. +Additional options for composer can be configured in `composer.json` by using the `config` section. ``` json { diff --git a/bin/composer b/bin/composer index 0f31a0228..dd23d99dc 100755 --- a/bin/composer +++ b/bin/composer @@ -35,12 +35,11 @@ if (isset($packageConfig['config']) && is_array($packageConfig['config'])) { $packageConfig['config'] = $composerConfig; } -// easy local access -$vendorPath = $packageConfig['config']['vendor-dir']; +$vendorDir = $packageConfig['config']['vendor-dir']; // initialize repository manager $rm = new Repository\RepositoryManager(); -$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorPath.'/.composer/installed.json'))); +$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json'))); $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository'); $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); @@ -55,9 +54,9 @@ $dm->setDownloader('pear', new Downloader\PearDownloader()); $dm->setDownloader('zip', new Downloader\ZipDownloader()); // initialize installation manager -$im = new Installer\InstallationManager($vendorPath); -$im->addInstaller(new Installer\LibraryInstaller($vendorPath, $dm, $rm->getLocalRepository(), null)); -$im->addInstaller(new Installer\InstallerInstaller($vendorPath, $dm, $rm->getLocalRepository(), $im)); +$im = new Installer\InstallationManager($vendorDir); +$im->addInstaller(new Installer\LibraryInstaller($vendorDir, $dm, $rm->getLocalRepository(), null)); +$im->addInstaller(new Installer\InstallerInstaller($vendorDir, $dm, $rm->getLocalRepository(), $im)); // load package $loader = new Package\Loader\ArrayLoader($rm); diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index a95ea66fb..efcb3979d 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -54,6 +54,8 @@ EOF; // autoload_namespace.php generated by Composer +$baseDir = dirname(__DIR__); + return array( EOF; @@ -77,7 +79,7 @@ EOF; foreach ($autoloads['psr-0'] as $def) { if (!$this->isAbsolutePath($def['path'])) { $def['path'] = substr($def['path'], strlen($vendorPath)); - $baseDir = "dirname(__DIR__)."; + $baseDir = '$baseDir . '; } else { $baseDir = ''; } diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index f2d3f5af2..4ae07c1a4 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -32,21 +32,21 @@ class InstallationManager /** * Creates an instance of InstallationManager - * - * @param string $vendorPath Relative path to the vendor directory + * + * @param string $vendorDir Relative path to the vendor directory * @throws \InvalidArgumentException */ - public function __construct($vendorPath = 'vendor') + public function __construct($vendorDir = 'vendor') { - if (substr($vendorPath, 0, 1) === '/' || substr($vendorPath, 1, 1) === ':') { + if (substr($vendorDir, 0, 1) === '/' || substr($vendorDir, 1, 1) === ':') { $basePath = getcwd(); - if (0 !== strpos($vendorPath, $basePath)) { - throw new \InvalidArgumentException("Vendor path ($vendorPath) must be within the current working directory ($basePath)."); + if (0 !== strpos($vendorDir, $basePath)) { + throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath)."); } // convert to relative path - $this->vendorPath = substr($vendorPath, strlen($basePath)+1); + $this->vendorPath = substr($vendorDir, strlen($basePath)+1); } else { - $this->vendorPath = $vendorPath; + $this->vendorPath = $vendorDir; } } @@ -174,7 +174,7 @@ class InstallationManager /** * Returns the vendor path - * + * * @param boolean $absolute Whether or not to return an absolute path * @return string path */ diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index 73c547066..9182ad308 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -209,7 +209,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase public function testGetVendorPathAbsolute() { $manager = new InstallationManager('vendor'); - $this->assertEquals(realpath('').DIRECTORY_SEPARATOR.'vendor', $manager->getVendorPath(true)); + $this->assertEquals(getcwd().DIRECTORY_SEPARATOR.'vendor', $manager->getVendorPath(true)); } public function testGetVendorPathRelative()