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`
|
3. Run Composer: `php composer.phar install`
|
||||||
4. Browse for more packages on [Packagist](http://packagist.org).
|
4. Browse for more packages on [Packagist](http://packagist.org).
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ in a system wide way.
|
||||||
Configuration
|
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
|
``` json
|
||||||
{
|
{
|
||||||
|
|
11
bin/composer
11
bin/composer
|
@ -35,12 +35,11 @@ if (isset($packageConfig['config']) && is_array($packageConfig['config'])) {
|
||||||
$packageConfig['config'] = $composerConfig;
|
$packageConfig['config'] = $composerConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// easy local access
|
$vendorDir = $packageConfig['config']['vendor-dir'];
|
||||||
$vendorPath = $packageConfig['config']['vendor-dir'];
|
|
||||||
|
|
||||||
// initialize repository manager
|
// initialize repository manager
|
||||||
$rm = new Repository\RepositoryManager();
|
$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('composer', 'Composer\Repository\ComposerRepository');
|
||||||
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
|
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
|
||||||
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
|
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
|
||||||
|
@ -55,9 +54,9 @@ $dm->setDownloader('pear', new Downloader\PearDownloader());
|
||||||
$dm->setDownloader('zip', new Downloader\ZipDownloader());
|
$dm->setDownloader('zip', new Downloader\ZipDownloader());
|
||||||
|
|
||||||
// initialize installation manager
|
// initialize installation manager
|
||||||
$im = new Installer\InstallationManager($vendorPath);
|
$im = new Installer\InstallationManager($vendorDir);
|
||||||
$im->addInstaller(new Installer\LibraryInstaller($vendorPath, $dm, $rm->getLocalRepository(), null));
|
$im->addInstaller(new Installer\LibraryInstaller($vendorDir, $dm, $rm->getLocalRepository(), null));
|
||||||
$im->addInstaller(new Installer\InstallerInstaller($vendorPath, $dm, $rm->getLocalRepository(), $im));
|
$im->addInstaller(new Installer\InstallerInstaller($vendorDir, $dm, $rm->getLocalRepository(), $im));
|
||||||
|
|
||||||
// load package
|
// load package
|
||||||
$loader = new Package\Loader\ArrayLoader($rm);
|
$loader = new Package\Loader\ArrayLoader($rm);
|
||||||
|
|
|
@ -54,6 +54,8 @@ EOF;
|
||||||
|
|
||||||
// autoload_namespace.php generated by Composer
|
// autoload_namespace.php generated by Composer
|
||||||
|
|
||||||
|
$baseDir = dirname(__DIR__);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
@ -77,7 +79,7 @@ EOF;
|
||||||
foreach ($autoloads['psr-0'] as $def) {
|
foreach ($autoloads['psr-0'] as $def) {
|
||||||
if (!$this->isAbsolutePath($def['path'])) {
|
if (!$this->isAbsolutePath($def['path'])) {
|
||||||
$def['path'] = substr($def['path'], strlen($vendorPath));
|
$def['path'] = substr($def['path'], strlen($vendorPath));
|
||||||
$baseDir = "dirname(__DIR__).";
|
$baseDir = '$baseDir . ';
|
||||||
} else {
|
} else {
|
||||||
$baseDir = '';
|
$baseDir = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,21 @@ class InstallationManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of 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
|
* @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();
|
$basePath = getcwd();
|
||||||
if (0 !== strpos($vendorPath, $basePath)) {
|
if (0 !== strpos($vendorDir, $basePath)) {
|
||||||
throw new \InvalidArgumentException("Vendor path ($vendorPath) must be within the current working directory ($basePath).");
|
throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath).");
|
||||||
}
|
}
|
||||||
// convert to relative path
|
// convert to relative path
|
||||||
$this->vendorPath = substr($vendorPath, strlen($basePath)+1);
|
$this->vendorPath = substr($vendorDir, strlen($basePath)+1);
|
||||||
} else {
|
} else {
|
||||||
$this->vendorPath = $vendorPath;
|
$this->vendorPath = $vendorDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ class InstallationManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the vendor path
|
* Returns the vendor path
|
||||||
*
|
*
|
||||||
* @param boolean $absolute Whether or not to return an absolute path
|
* @param boolean $absolute Whether or not to return an absolute path
|
||||||
* @return string path
|
* @return string path
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -209,7 +209,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
public function testGetVendorPathAbsolute()
|
public function testGetVendorPathAbsolute()
|
||||||
{
|
{
|
||||||
$manager = new InstallationManager('vendor');
|
$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()
|
public function testGetVendorPathRelative()
|
||||||
|
|
Loading…
Reference in New Issue