How to Specify Composer Install Path

How to specify Composer install path?

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.*"
}
}

Running composer in a different directory than current

Try composer install -h. There you'll find an option --working-dir (or -d). And that's what you're looking for.

Then run:

composer install --working-dir=/home/someuser/myproject

You can find more in composer docs.

Depending on your operating system, the = might need to be removed:

composer install --working-dir /home/someuser/myproject

Setting a package install-path for composer

It can be solved by adding installer-name to the extra key in the package's composer.json file.

"extra": {
"installer-name": "foobar",
}

Composer install to target folder

Try setting config.vendor-dir in your composer.json like this:

{
"config": {
"vendor-dir": "some-folder"
}
}

How to set the install directory for a package on the package, instead of on the project?

This is not possible, and the documentation says so explicitly:

[...] The ability for a package author to determine where a package will be installed either through setting the path directly in their composer.json or through a dynamic package type: "type": "framework-install-here".

It has been proposed many times. Even implemented once early on and then removed. Installers won't do this because it would allow a single package author to wipe out entire folders without the user's consent. That user would then come here to yell at us.

(Emphasis mine)

The two keys you are using (installer-paths and installer-name) serve a different purpose than what you imagine:

  • installer-name: allows the package author (you) to say your package should be installed under a different directory than vendor/name. In your case, instead of being installed on vendor/demo/contentfeed, it would be installed under vendor/demo/packages (because of your setting in composer.json)
  • installer-paths: allows the package consumer to set a custom install path for a certain package or packages or package family. On a package composer.json has no effect, this setting is only for the project configuration.

Composer - specify `composer.json` path

I would suggest you take a look at this:
https://getcomposer.org/doc/03-cli.md#environment-variables

COMPOSER

By setting the COMPOSER env variable it is possible to set the filename of composer.json to something else.

For example:

COMPOSER=composer-other.json php composer.phar install

The generated lock file will use the same name: composer-other.lock in this example.

Install package into custom directory Composer

If you want to use the installer-paths option the package you want to be installed in a different path must require composer/installers.

In your case the aheinze/cockpit package doesn't require composer/installers as you can see in its composer.json at github.

Have a look at the composer documentation for custom paths and you see that it tells you:

Note: You cannot use this to change the path of any package. This is only applicable to packages that require composer/installers and use a custom type that it handles.

This means you are not able to change the install path of this specific package.
Anyway I don't see any necessity to install it into any different directory from the default vendor folder.

composer to install a package or module in a custom path?

there we should define the custom path and defining that which module or package should install in that path.

like this

"installer-paths": {

// custom path with the list of items that should installed there.

"modules/patched/{$name}": [
"drupal/signature_field",
"drupal/eck",
"drupal/auto_entitylabel"
],
}

The package or module should be in your require section as well.

"require": {
"composer/installers": "^1.0.24",
"drupal/auto_entitylabel": "2.x-dev",
"drupal/signature_field": "^1.0@RC",
"drupal/eck": "^1.0@alpha",
}

Composer install path for custom package

Finally figured it out after trying lots of different things. I think I was missing two things:

In the package declaration I changed it to have the "type": "wordpress-plugin", and then in the requires I had to add "composers/installers": "~1.0" like so (also note that the extra was removed entirely):

{
"name": "mycompany/wordpress-install",
"description": "Themes and plugins for our wordpress install.",
"authors": [
{
"name": "Me",
"email": "example@example.net"
}
],
"require": {
"composer/installers": "~1.0.0",
"deliciousdays/cforms": "14.5.2"
},
"repositories": [
{
"type": "package",
"package": {
"name": "deliciousdays/cforms",
"version": "14.5.2",
"type": "wordpress-plugin",
"dist": {
"url": "http://www.deliciousdays.com/download/cforms-v14.5.zip",
"type": "zip"
}
}
}
]
}

I still have been unable to figure out how to get a custom package to install to a directory of my choosing even with the composer/installers require in there. It just seems to ignore everything until I've added a type to the object, and then it forces it to download into the location defined by that type, based on how composer/installers decided to map it.

But I think this will work for now... If anyone knows how to make it download into, say, "myfolder/something/cforms" I'll accept your answer.



Related Topics



Leave a reply



Submit