在哪里可以找到作曲家的全球包裹?

对于一个用于 SublimText 的插件,我需要在全球范围内安装一个作曲家软件包。

为了做到这一点,我必须运行以下命令:

composer global require "asm89/twig-lint" "@stable"

安装程序开始运行,几秒钟后软件包就安装好了。

第二步是在我的 Sublime Text 配置文件中添加一些代码行:

{
"user": {
"paths": {
"windows": ["C:\\Users\\yourname\\.composer\\vendor\\bin"]
},
}
}

但是,这个插件不能工作。所以我决定检查一下路径。而且似乎在我的配置文件目录中没有 .composer目录。它也不在我的 php目录中。我到处都找不到。

我想知道是否有办法找到这个目录,并希望任何建议,可以帮助我得到这个插件的工作。

107799 次浏览

You can query Composer to find where it has set the user $COMPOSER_HOME directory.

composer config --list --global

The [home] ... line refers to the default value of $COMPOSER_HOME.


The word home can be used as a single parameter as well to show the configuration value.

Example (Windows):

> composer -n config --global home
C:\Users\<user>\AppData\Roaming\Composer

Example (Linux):

$ composer -n config --global home
/home/<user>/.composer

Just as a final confirmation - the 'yourname' part in the configuration, would very likely need to be updated with your own Windows username - composer config will say where it puts the files.

You may find in ~/.config/composer/vendor/bin

On Windows, mine was /Users/taylor/AppData/Roaming/Composer/bin

Run the command

composer config --list --global | grep -w home

You can find the find the [home] with composer path, similar to this one.

[home] /home/example_username/.config/composer

Ubuntu 20.04:

~/.config/composer/vendor

You can use

composer global config bin-dir --absolute

Example

PATH=$(composer global config bin-dir --absolute --quiet):$PATH

You need --absolute to get value expanded, and --quiet to discard diagnostics of composer global changing working directory. This was tested with composer 1.10.16 and 2.0.1.

See https://github.com/composer/composer/issues/9354#issuecomment-716827067

~/.config/composer/vendor/bin/laravel adding this to my bashrc file as a alias works on ubuntu 20.04

For composer v2:

composer global config --list

Check the output and find [vendor-dir] parameter. Or use grep:

composer global config --list | grep "vendor-dir"