未找到 Laravel“代客安装”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37085102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel "valet install" not found
提问by Brotzka
I am trying to set up Laravels Valet (Valet is a Laravel development environment for Mac). Everything works until it comes to the command "valet install". This command must be executed in terminal. But I got the error "command not found". Any ideas, why? Do I have to update my PATH or something else?
我正在尝试设置 Laravel Valet(Valet 是 Mac 的 Laravel 开发环境)。一切正常,直到出现“代客安装”命令。此命令必须在终端中执行。但是我收到错误“找不到命令”。任何想法,为什么?我是否必须更新我的 PATH 或其他内容?
I switched to OS X a few days ago. Before that, I was a windows user. So I am a total newbie.
几天前我切换到 OS X。在此之前,我是 Windows 用户。所以我是一个完全的新手。
回答by Mohamed Said
Yes, you need to make sure that ~/.composer/vendor/bin
directory is in your system's PATH
, you can check this by running:
是的,您需要确保该~/.composer/vendor/bin
目录在您的系统中PATH
,您可以通过运行来检查:
echo $PATH
If you can't see it there, then you need to add this to your ~/.bash_profile
:
如果你在那里看不到它,那么你需要将它添加到你的~/.bash_profile
:
export PATH=$PATH:~/.composer/vendor/bin
回答by rjb
If you're getting the error message "valet: command not found", it's likely that PHP's Composer is not in your PATH
variable, for instance:
如果您收到错误消息“ valet: command not found”,则很可能是 PHP 的 Composer 不在您的PATH
变量中,例如:
$ valet install
-bash: valet: command not found
You can confirm if Laravel Valetwas successfully installed by running the following command:
您可以通过运行以下命令来确认Laravel Valet 是否已成功安装:
ls -al ~/.composer/vendor/bin/valet
If successfull, you'll see the symlink for Valet in Composer's bin
directory pointing to Laravel in the vendor
directory:
如果成功,您将在 Composer 的bin
目录中看到 Valet 的符号链接指向目录中的 Laravel vendor
:
~/.composer/vendor/bin/valet@ -> ../laravel/valet/valet
To test whether your PATH
is missing Composer, try running the Valet command directly:
要测试您PATH
是否缺少 Composer,请尝试直接运行 Valet 命令:
~/.composer/vendor/bin/valet --version
If you're shown the Laravel version number, (e.g. Laravel Valet 2.0.4
), this indicates Valet is installed but you need to update your PATH
variableto include Composer for the valet
command to work globally.
如果您看到 Laravel 版本号(例如Laravel Valet 2.0.4
),这表明 Valet 已安装,但您需要更新您的PATH
变量以包含 Composer,以便valet
命令在全局范围内工作。
In your Terminal, execute the following command which will append Composer to your shell's PATH:
在您的终端中,执行以下命令,该命令会将 Composer 附加到您的 shell 的 PATH:
export PATH=$PATH:~/.composer/vendor/bin
For the changes to take effect, you'll need to exit and re-open your Terminal window or tab.
要使更改生效,您需要退出并重新打开终端窗口或选项卡。
Alternatively, you can simply source your shell's profile, which doesn't require quitting your active session:
或者,您可以简单地获取 shell 的配置文件,这不需要退出活动会话:
source ~/.bash_profile
If you have a different shell environment or you're using a shell other than Bash, you will need to source its configuration profile instead (e.g. .bashrc
, .zshrc
, config.fish
).
如果您有不同的 shell 环境,或者您使用的是 Bash 以外的 shell,则需要改为获取其配置文件(例如.bashrc
, .zshrc
, config.fish
)。
回答by Martins Gathu
Make sure that ~/.composer/vendor/bin directory is in your system's PATH, you can check this by running:
确保 ~/.composer/vendor/bin 目录在您系统的 PATH 中,您可以通过运行来检查:
echo $PATH
If not there, open your ~/.bash_profile and add this code:
如果没有,请打开您的 ~/.bash_profile 并添加以下代码:
export PATH=$PATH:~/.composer/vendor/bin
Then run:
然后运行:
composer global require laravel/valet --dev
Once it is done, run:
完成后,运行:
valet install
回答by Nicu Criste
I'm using oh-my-zsh so:
我正在使用 oh-my-zsh 所以:
echo "export PATH=$PATH:$HOME/.config/composer/vendor/bin" >> ~/.zshrc
source ~/.zshrc
You may replace .zshrc
with .bashrc
您可以替换.zshrc
为.bashrc
回答by Md Mazedul Islam Khan
If you have a fresh installation, you may not have the PATH
variable contains your home path. So, adding the $HOME
variable would require like the following:
如果您是全新安装,则可能没有PATH
包含您的主路径的变量。因此,添加$HOME
变量需要如下所示:
export PATH="$PATH:$HOME/.composer/vendor/bin
export PATH="$PATH:$HOME/.composer/vendor/bin
回答by Mete Kabak
with new composer installation, you need to add a new path which is
使用新的作曲家安装,您需要添加一个新路径
export PATH=$PATH:~/.config/composer/vendor/bin
Then you need to
那么你需要
chown YOUR_USERNAME ~/.config
for accessing composer packages without sudo command.
用于在没有 sudo 命令的情况下访问 composer 包。
回答by VipinKundal
This command might solve your problem
此命令可能会解决您的问题
test -d ~/.composer && bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install
回答by Kornel
In Ubuntu 18.04 do this:
在 Ubuntu 18.04 中这样做:
echo "export PATH=$PATH:$HOME/.config/composer/vendor/bin" >> ~/.bashrc
source ~/.bashrc
回答by Nuruzzaman Milon
Add ~/.composer/vendor/bin
directory to your PATH
variable.
将~/.composer/vendor/bin
目录添加到您的PATH
变量中。