ribrit / installers
A multi-framework Composer library installer
Installs: 65
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 412
Type:composer-plugin
Requires
- composer-plugin-api: ^1.0
Requires (Dev)
- composer/composer: 1.0.*@dev
- phpunit/phpunit: ^4.8.36
Replaces
- roundcube/plugin-installer: *
- shama/baton: *
This package is not auto-updated.
Last update: 2024-12-13 02:20:22 UTC
README
This is for PHP package authors to require in their composer.json
. It will
install their package to the correct location based on the specified package
type.
The goal of Installers is to be a simple package type to install path map. Users can also customize the install path per package and package authors can modify the package name upon installing.
Installers isn't intended on replacing all custom installers. If your package requires special installation handling then by all means, create a custom installer to handle it.
Natively Supported Frameworks:
The following frameworks natively work with Composer and will be
installed to the default vendor
directory. composer/installers
is not needed to install packages with these frameworks:
- Aura
- Symfony2
- Yii
- Yii2
Current Supported Package Types
Stable types are marked as bold, this means that installation paths for those type will not be changed. Any adjustment for those types would require creation of brand new type that will cover required changes.
Example composer.json
File
This is an example for a CakePHP plugin. The only important parts to set in your
composer.json file are "type": "cakephp-plugin"
which describes what your
package is and "require": { "composer/installers": "~1.0" }
which tells composer
to load the custom installers.
{ "name": "you/ftp", "type": "cakephp-plugin", "require": { "composer/installers": "~1.0" } }
This would install your package to the Plugin/Ftp/
folder of a CakePHP app
when a user runs php composer.phar install
.
So submit your packages to packagist.org!
Custom Install Paths
If you are consuming a package that uses the composer/installers
you can
override the install path with the following extra in your composer.json
:
{ "extra": { "installer-paths": { "your/custom/path/{$name}/": ["shama/ftp", "vendor/package"] } } }
A package type can have a custom installation path with a type:
prefix.
{ "extra": { "installer-paths": { "your/custom/path/{$name}/": ["type:wordpress-plugin"] } } }
You can also have the same vendor packages with a custom installation path by
using the vendor:
prefix.
{ "extra": { "installer-paths": { "your/custom/path/{$name}/": ["vendor:my_organization"] } } }
These would use your custom path for each of the listed packages. The available
variables to use in your paths are: {$name}
, {$vendor}
, {$type}
.
Custom Install Names
If you're a package author and need your package to be named differently when
installed consider using the installer-name
extra.
For example you have a package named shama/cakephp-ftp
with the type
cakephp-plugin
. Installing with composer/installers
would install to the
path Plugin/CakephpFtp
. Due to the strict naming conventions, you as a
package author actually need the package to be named and installed to
Plugin/Ftp
. Using the following config within your package composer.json
will allow this:
{ "name": "shama/cakephp-ftp", "type": "cakephp-plugin", "extra": { "installer-name": "Ftp" } }
Please note the name entered into installer-name
will be the final and will
not be inflected.
Disabling installers
There may be time when you want to disable one or more installers from composer/installers
.
For example, if you are managing a package or project that uses a framework specific installer that
conflicts with composer/installers
but also have a dependency on a package that depends on composer/installers
.
Installers can be disabled for your project by specifying the extra
installer-disable
property. If set to true
, "all"
, or "*"
all installers
will be disabled.
{ "extra": { "installer-disable": true } }
Otherwise a single installer or an array of installers may be specified.
{ "extra": { "installer-disable": [ "cakephp", "drupal" ] } }
Note: Using a global disable value (true
, "all"
, or "*"
) will take precedence over individual
installer names if used in an array. The example below will disable all installers.
{ "extra": { "installer-disable": [ "drupal", "all" ] } }
Should we allow dynamic package types or paths? No.
What are they? 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.
Anyone still wanting this capability should consider requiring https://github.com/oomphinc/composer-installers-extender.