From 6e40822abba862196140514be5cb90f1229a40b3 Mon Sep 17 00:00:00 2001 From: Kyle Robinson Young Date: Wed, 18 Jul 2012 21:19:03 -0700 Subject: [PATCH] Add FAQ on how to install to a custom directory --- ...install-a-package-in-a-custom-directory.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 doc/faqs/how-do-i-install-a-package-in-a-custom-directory.md diff --git a/doc/faqs/how-do-i-install-a-package-in-a-custom-directory.md b/doc/faqs/how-do-i-install-a-package-in-a-custom-directory.md new file mode 100644 index 000000000..e20e1a405 --- /dev/null +++ b/doc/faqs/how-do-i-install-a-package-in-a-custom-directory.md @@ -0,0 +1,47 @@ +# How do I install a package in a custom directory? + +Composer can be configured to install packages to a folder other than the +default `vendor` folder. An simple way is to use +[composer/installers](https://github.com/composer/installers) and if you're +using a framework, chances are a custom directory has been already configured +for you. + +If you're a **package author** and want your package installed to a custom +directory, simply require `composer/installers` and set the appropriate `type`. +This is common if your package is intended for a specific framework such as +CakePHP, Drupal or WordPress. Here is an example composer.json file for a +WordPress theme: + +``` json +{ + "name": "you/themename", + "type": "wordpress-theme", + "require": { + "composer/installers": "*" + } +} +``` + +Now when your theme is installed with Composer it will be placed into +`wp-content/themes/themename/` folder. Check the +[current supported types](https://github.com/composer/installers#current-supported-types) +for your package. + +As a **package consumer** you can set or override the install path for each +package with the `installer-paths` extra. A useful example would be for a +Drupal multisite setup where the package should be installed into your sites +subdirectory. Here we are overriding the install path for a module that uses +composer/installers: + +``` json +{ + "extra": { + "installer-paths": { + "sites/example.com/modules/{$name}": ["vendor/package"] + } + } +} +``` + +Now the package would be installed to your folder location, rather than the default +composer/installers determined location.