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.


当前回答

我这样做了,它在osx上工作:

在终点站吃午餐

 nano ~/.bash_profile 

粘贴

 export PATH=~/.composer/vendor/bin:$PATH

按control + x

按y键

按回车键

其他回答

将此文件夹放在PATH环境变量类型上

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

这将把文件夹追加到您现有的PATH,但是,它只对当前终端会话是活动的。

如果您想自动设置它,这取决于您正在使用的shell。对于bash,您可以将这一行附加到$HOME/。使用您最喜欢的编辑器或在shell上键入以下内容

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

为了检查它是否工作,登出并再次登录或执行

source ~/.bashrc

在壳上。

PS:对于没有~/的其他系统。Bashrc,你也可以把它放到~/.bash_profile中

PSS:对于最近的laravel,你需要放$HOME/。config/composer/vendor/bin目录。

PSSS:如果你想把这个文件夹也放在其他shell或GUI的路径上,你应该将上述导出命令附加到~/。个人资料(参见https://help.ubuntu.com/community/EnvironmentVariables)。

要解决这个问题,请确保您找到了作曲家的路径。phar第一

我的例子是这样的

alias composer="php /Users/Your-username/composer.phar"

进入cd Users >您的用户> Command ls,查看composer. sh是否存在。Phar在那里,如果是,然后将上面的行添加到.bash_profile。请确保将用户名更改为您自己的用户名。

希望这能帮到你

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

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

详细说明:

在你的~/。Bashrc添加这些行:

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

然后重新加载:

source ~/.bashrc

检查是否正确添加:

echo $PATH

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/web/bin:~/.composer/vendor/bin

在Ubuntu 16.04 LTS中,我在全球安装了作曲家,这对我来说很有效。

编辑您的主目录中的.bashrc文件,将其路径放到位于/your/home/.config/composer/vendor/bin的composer bin文件夹中

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

source ~/.bashrc

如果不行,请验证composer bin目录的路径,然后关闭并重新打开终端。否则,请尝试在Ubuntu中注销和登录。

也适用于ubuntu 18.04。感谢@chifliiiii的反馈。