Minor adjustments to merged PR
parent
5b87a02767
commit
f5b7e968b2
|
@ -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
|
||||
{
|
||||
|
|
11
bin/composer
11
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);
|
||||
|
|
|
@ -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 = '';
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue