iwink / composer-global-installer
Plugin to install Composer dependencies in a global directory.
Installs: 359
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 5
Forks: 1
Open Issues: 1
Type:composer-plugin
Requires
- php: >=7.4
- composer-plugin-api: ^2.1
Requires (Dev)
- composer/composer: ^2.1
- justinrainbow/json-schema: ^5.2
- phpunit/phpunit: ^9.5
README
A plugin to install stable, remote Composer packages in a global
vendor directory. The path to a global installed package is
[global-vendor-dir]/[pretty-package-name]/[pretty-package-version]
; for example, symfony/console:v5.3.1
might be
found under /usr/local/lib/composer/vendor/symfony/console/v5.3.1
. It creates symlinks in the local vendor directory
(/path/to/project/vendor
) to assist IDEs. The
autoloader will point to the resolved global vendor/package directory. You should make sure the global vendor directory
is writable.
Installation
To install this package, run composer require iwink/composer-global-installer
. It's also possible to install the
plugin global: composer global require iwink/composer-global-installer
.
Options
You can configure the plugin using the extra.global-installer
key in composer.json
(and in the global
$COMPOSER_HOME/composer.json
):
path
: Path to global vendor directory. (default:/usr/local/lib/composer/vendor/
)exclude
: Array of excluded package names (including vendor prefix), these packages will be installed locally.exclude-bin
: Whether to exclude any packages that hold a binary. (default:false
)stabilities
: Array of supported branch stabilities. (default:["alpha", "beta", "RC", "stable"]
)
Example:
{ "extra": { "global-installer": { "path": "path/to/global/vendor/", "exclude": [ "vendor/package", "vendor/package-two" ], "exclude-bin": true, "stabilities": ["stable"] } } }
To disable the entire plugin, you can pass false
to the extra.global-installer
key:
{ "extra": { "global-installer": false } }
Caveats
Unsupported libraries
Some libraries, like
laminas/laminas-zendframework-bridge
and
phpunit/phpunit
, expect the package to be installed locally. If one
or more of your projects depend on such libraries, you can exclude them in the global composer configuration:
composer global config --json extra.global-installer.exclude '["laminas/laminas-zendframework-bridge", "phpunit/phpunit"]'
Packages with patches
If you use a seperate plugin (for example cweagans/composer-patches
)
to apply patches to packages, it might not be a good idea to install those packages globally.
Other projects which use the same package will receive the changes from the applied patch as well.
To prevent this, we recommend excluding packages which you have patched.