如何指定编写器安装路径?

我的定义是:

{
"repositories": [
{
"type": "package",
"package": {
"name": "symfony/sfGuardPlugin",
"version": "4.0.2",
"dist": {
"url": "http://plugins.symfony-project.org/get/sfGuardPlugin/sfGuardPlugin-4.0.2.tgz",
"type": "tar"
}
}
}
],
"require": {
"symfony/sfGuardPlugin": "4.0.*"
}
}

我正在使用 Symfony 1,我想在 plugins/sfGuardPlugin/上安装它们。我如何指定它们?

104293 次浏览

It seems that you can define the vendor dir to be something else (plugins in your case):

{
"config": {
"vendor-dir": "plugins"
}
}

Then, you might rename the package name to not have a level dir inside, like:

        "package": {
"name": "sfGuardPlugin",

So, your composer.json should look like this:

{
"config": {
"vendor-dir": "plugins"
},
"repositories": [
{
"type": "package",
"package": {
"name": "sfGuardPlugin",
"version": "4.0.2",
"dist": {
"url": "http://plugins.symfony-project.org/get/sfGuardPlugin/sfGuardPlugin-4.0.2.tgz",
"type": "tar"
}
}
}
],
"require": {
"sfGuardPlugin": "4.0.*"
}
}

Edit

Using this configuration, you will get the path (which is of course not good for symfony):

plugins/sfGuardPlugin/sfGuardPlugin-4.0.2/

I found a workaround with this composer.json:

{
"config": {
"vendor-dir": "plugins"
},
"repositories": [
{
"type": "package",
"package": {
"name": "sfGuardPlugin",
"version": "4.0.2",
"source": {
"url": "http://svn.symfony-project.com/plugins/sfGuardPlugin/",
"type": "svn",
"reference": "branches/1.3/"
}
}
}
],
"require": {
"sfGuardPlugin": "4.0.*"
}
}

You can also use composer/installers, a multi-framework composer library installer with the "symfony1-plugin" package type. This is what my composer.json file looks like, in order for it to install both Symfony 1.4 (in lib/vendor) and plugins in (/plugins):

{
"config": {
"vendor-dir": "lib/vendor"
},
"repositories": {
"symfony": {
"type": "package",
"package": {
"name": "symfony/symfony1",
"version": "1.4",
"dist": {
"url": "https://github.com/symfony/symfony1/zipball/1.4",
"type": "zip"
}
}
},
"sfResquePlugin" : {
"type": "package",
"package": {
"name": "devpips/sfResquePlugin",
"type": "symfony1-plugin",
"version": "0.1",
"dist": {
"url": "https://github.com/devpips/sfResquePlugin/zipball/master",
"type": "zip"
}
}
}
},
"require": {
"composer/installers": "dev-master",
"symfony/symfony1": "1.4",
"devpips/sfResquePlugin":"0.1"
}
}

See COMPOSER_VENDOR_DIR environment variable.

By setting this var you can make Composer install the dependencies into a directory other than vendor.

Can be helpful in the case you want to override this in a particular environment such as vagrant or docker where you wouldn't want this to be in a shared folder / volume.

And as J0k said, there's vendor-dir in config section of composer.json

Defaults to vendor. You can install dependencies into a different directory if you want to. $HOME and ~ will be replaced by your home directory's path in vendor-dir and all *-dir options below.