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.


当前回答

对于Linux Mint 18:编辑~/。Bashrc并在底部添加这一行:

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

然后resource .bashrc(在控制台中输入):

source ~/.bashrc (or close and reopen the terminal)

通过在控制台中输入测试它:

echo $PATH

或者输入console:

laravel

其他回答

在Yosemite (OS X 10.10.5)上设置PATH,使用下面的命令:

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

重新加载退出终端并重新启动或使用:

source ~/.bash_profile

帮助了我,希望它能帮助其他人!

针对Ubuntu 16.04

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

source ~/.bashrc

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

对于Linux Mint 18:编辑~/。Bashrc并在底部添加这一行:

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

然后resource .bashrc(在控制台中输入):

source ~/.bashrc (or close and reopen the terminal)

通过在控制台中输入测试它:

echo $PATH

或者输入console:

laravel

打开Mac终端:

vi ~/.bashrc

如果你没有使用过vi,一开始看起来可能有点滑稽,所以仔细输入以下代码,按顺序:

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

按ESC

:
w

按回车键

:
q

按回车键

现在您应该已经返回到正常的终端视图。

检查编写器现在有正确的路径:

cd ~/.composer
echo $PATH

如果您看到包含您的文件目录的路径(例如/Users/JeffStrongman/.composer/vendor/bin),那么您就可以开始了。

cd

然后运行安装。我在配置我的Mac使用Laravel Valet时遇到了这个问题。

示例(可选)

valet install