1
0
Fork 0

It is possible to set an "install-dir" option for a package now

This let's you completely customize the path needed for your custom
package. So you can specify paths directly on top level and are not forced
to install your packages under the vendor/ directory.

Example:

{
    "name": "my-project",
    "version": "1.0.0",
    "repositories": {
        "MyRepo": {
            "package": {
                "name": "mypackage",
                "version": "1.0",
                "install-dir": "lib/src/mypackage"
                "source": {
                    "url": "https://github.com/awesomepackages/mypackage.git",
                    "type": "git",
                    "reference": "some-tag"
                }
            }
        }
    },
    "require": {
        "mypackage" : "1.0"
    }
}
pull/115/head
Ben Bieker 2011-11-17 15:19:58 +01:00
parent 1d5a03eedc
commit 36dd725a88
3 changed files with 20 additions and 0 deletions

View File

@ -123,6 +123,11 @@ class LibraryInstaller implements InstallerInterface
*/ */
public function getInstallPath(PackageInterface $package) public function getInstallPath(PackageInterface $package)
{ {
$installDir = $package->getInstallDir();
if (isset($installDir))
{
return $installDir;
}
$targetDir = $package->getTargetDir(); $targetDir = $package->getTargetDir();
return ($this->directory ? $this->directory.'/' : '') . $package->getName() . ($targetDir ? '/'.$targetDir : ''); return ($this->directory ? $this->directory.'/' : '') . $package->getName() . ($targetDir ? '/'.$targetDir : '');
} }

View File

@ -27,6 +27,7 @@ abstract class BasePackage implements PackageInterface
protected $prettyName; protected $prettyName;
protected $repository; protected $repository;
protected $id; protected $id;
protected $installDir;
/** /**
* All descendants' constructors should call this parent constructor * All descendants' constructors should call this parent constructor
@ -92,6 +93,16 @@ abstract class BasePackage implements PackageInterface
return $this->id; return $this->id;
} }
public function setInstallDir($dir)
{
$this->installDir = $dir;
}
public function getInstallDir()
{
return $this->installDir;
}
/** /**
* Checks if the package matches the given constraint directly or through * Checks if the package matches the given constraint directly or through
* provided or replaced packages * provided or replaced packages

View File

@ -53,6 +53,10 @@ class ArrayLoader
$package->setTargetDir($config['target-dir']); $package->setTargetDir($config['target-dir']);
} }
if (isset($config['install-dir'])) {
$package->setInstallDir($config['install-dir']);
}
if (isset($config['repositories'])) { if (isset($config['repositories'])) {
$repositories = array(); $repositories = array();
foreach ($config['repositories'] as $repoName => $repo) { foreach ($config['repositories'] as $repoName => $repo) {