sh:php:在 git bash windows 8 中找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22801758/
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
sh: php: command not found in git bash windows 8
提问by Prajan Karmacharya
I'm running php composer.phar install
from git bash CLI and it shows sh:php: Command not found.
Though I have set environment variable path to my wamp/bin/php/php5.4.16/
我php composer.phar install
从 git bash CLI运行,它显示 sh:php: Command not found。虽然我已经将环境变量路径设置为 wamp/bin/php/php5.4.16/
回答by lnepal
You are required to put the directory that has php.exe in your WAMP installation into environment variable PATH. It is generally like C:\wamp\bin\php.
您需要将 WAMP 安装中包含 php.exe 的目录放入环境变量 PATH 中。它一般类似于 C:\wamp\bin\php。
Where \php\ is the directory containing php.exe.
其中\php\ 是包含php.exe 的目录。
回答by Prajan Karmacharya
- Set php env. variable as mentioned here.(you can test it easily using this command:??????????????????
php -r "echo 1;"
orphp -v
) - restart git shell
if composer.phar does not exists, run this (more info):???????????????????????????????????????????????????????????????????
php -r "readfile('https://getcomposer.org/installer');" | php
run
php composer.phar install
finally
- 设置 php 环境。这里提到的变量。(您可以使用以下命令轻松测试:??????????????????
php -r "echo 1;"
或php -v
) - 重新启动git shell
如果 composer.phar 不存在,运行这个(更多信息):??????????????????????????????????? ????????????????????????????????????
php -r "readfile('https://getcomposer.org/installer');" | php
php composer.phar install
最后运行
Run php without git shell:
在没有 git shell 的情况下运行 php:
- Locate
C:\wamp\bin\php
- Hold SHIFT and click with right mousebutton on folder
phpX.Y.ZZ
- Select
Open command prompt window here
- run any php command like
php parameters
- 定位
C:\wamp\bin\php
- 按住 SHIFT 并用鼠标右键单击文件夹
phpX.Y.ZZ
- 选择
Open command prompt window here
- 运行任何 php 命令,如
php parameters
回答by MIshi
Whether you are using gitbash or cmd you should run it as an administrator. Navigate to your project then type the command "composer install" it will work. Mine worked just fine.
无论您使用的是 gitbash 还是 cmd,您都应该以管理员身份运行它。导航到您的项目,然后键入命令“composer install”,它将起作用。我的工作得很好。