I'm on Ubuntu 14.04 and I've been trying all possible methods to install Laravel to no avail. Error messages everything I try. I'm now trying the first method in the quickstart documentation, that is, via Laravel Installer, but it says to "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the Laravel executable is found when you run the Laravel command in your terminal." so my question is, how do I do that? This may be a simple question but I'm really frustrated and would appreciate any help.


当前回答

我尝试了很多解决方案,但在Ubuntu 20.04上只有这个对我有效:

export PATH="$HOME/.composer/vendor/bin:$PATH"

其他回答

Composer bin目录被设置并存储在bin-dir配置变量中,根据您的设置可以有所不同。运行命令composer global config bin-dir——absolute会告诉你全局composer bin目录的绝对路径。使用这个命令,您可以修改.bash_profile,将其完全按照配置的方式添加到PATH中。

# Add Composer bin-dir to PATH if it is installed.
command -v composer >/dev/null 2>&1 && {
        COMPOSER_BIN_DIR=$(composer global config bin-dir --absolute 2> /dev/null)
        PATH="$PATH:$COMPOSER_BIN_DIR";
}
export PATH

我做了以上所有的事情,但它对我不起作用。

我只是把这个复制到我的终端,它为我工作。

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

对我来说,在Ubuntu 22.04中,这是可行的:

export PATH="$PATH:$HOME/.config/composer/vendor/bin"

在Fedora:

有些composer bin不在.composer目录中 所以你需要使用以下方法来定位它们:

locate composer | grep vendor/bin

然后在.bashrc中回显该部分

echo 'export PATH="$PATH:$HOME/{you_composer_vendor_path}"' >> ~/.bashrc

我的是"/.config/composer/vendor/bin" 干杯!

针对Ubuntu 16.04

echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc

source ~/.bashrc