Custom package installation path in Composer?

Is it possible to indicate that our own packages in Composer are installed in a different folder than vendor/ . I know that I can specify the folder where all the packages are installed, but this is not what I want. I want third-party packages to end with vendor/ and our own in the src/ folder.

Is it possible? We use Symfony 2 if that matters.

+7
source share
3 answers

Perhaps you should make your own installer: http://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-path-for-my-framework.md and use your own installer-paths

+5
source

I implemented this installation plugin to install packages in custom (custom) folders that you can simply include in your .json composer, follow the example and tell me if you have more questions :)

https://github.com/mnsami/composer-custom-directory-installer

composer-order Catalog-installer

Composer plugin for installing various types of composition packages in user directories outside the default installation path of the default linker, which is located in the vendor folder.

This is not another composer-installer library for supporting package types other than composer, i.e. application .. etc. This is just to add the flexibility of installing composite packages outside the provider's folder. This package only supports composer package types,

https://getcomposer.org/doc/04-schema.md#type

Type of package. By default, the library is used.

Package types are used for custom installation logic. If you have a package that needs special logic, you can define a non-standard type. It can be a symfony suite, a wordpress plugin, or a typo3 module. These types will be specific to certain projects, and they will need to be provided with an installer capable of installing packages of this type.

How to use

  • Include the composer plugin in the composer.json require section:
 "require":{ "php": ">=5.3", "mnsami/composer-custom-directory-installer": "1.1.*", "monolog/monolog": "*" } 
  • In the extra section, specify the custom directory that you want to install in:
  "extra":{ "installer-paths":{ "./monolog/": ["monolog/monolog"] } 

adding the installer-paths , you tell the composer to install the monolog package inside the monolog folder in the root directory.

  • As an added new feature, we added great flexibility in defining the boot directory in the same way as composer/installers , in other words, you can use variables like {$vendor} and {$name} in the installer-path section:
 "extra": { "installer-paths": { "./customlibs/{$vendor}/db/{$name}": ["doctrine/orm"] } } 

above the doctrine/orm package will be installed in the root folder of your project under customlibs .

Note

Composer type: project not supported in this installer, since packages with the project type only make sense with application shells, such as symfony/framework-standard-edition , which are needed by another package.

+3
source

If we still consider checking my library (based on the mina.nsami plugin):

https://github.com/ideaconnect/composer-custom-directory

Allows you to create custom paths:

 "extra":{ "installer-paths":{ "./monolog/": ["monolog/monolog"] } 

and even dynamic name replacements:

 "extra": { "installer-paths": { "./packages/{$name}": ["sourcepackage/package_A","sourcepackage/package_B","sourcepackage/package_B"] } }, 

and with a chain of flags that allows you to simply manipulate variables at runtime:

The following flags are currently supported:

 F - capitalizes first letter. P - changes all entries of a _ or - followed by a character to only that character, capitalized. 
0
source

All Articles