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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:16:22  来源:igfitidea点击:

sh: php: command not found in git bash windows 8

phpgit

提问by Prajan Karmacharya

I'm running php composer.phar installfrom 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

  1. Set php env. variable as mentioned here.(you can test it easily using this command:?????????????????? php -r "echo 1;"or php -v)
  2. restart git shell
  3. if composer.phar does not exists, run this (more info):??????????????????????????????????????????????????????????????????? php -r "readfile('https://getcomposer.org/installer');" | php

  4. run php composer.phar installfinally

  1. 设置 php 环境。这里提到的变量(您可以使用以下命令轻松测试:??????????????????php -r "echo 1;"php -v
  2. 重新启动git shell
  3. 如果 composer.phar 不存在,运行这个(更多信息):??????????????????????????????????? ???????????????????????????????????? php -r "readfile('https://getcomposer.org/installer');" | php

  4. php composer.phar install最后运行



Run php without git shell:

在没有 git shell 的情况下运行 php:

  1. Locate C:\wamp\bin\php
  2. Hold SHIFT and click with right mousebutton on folder phpX.Y.ZZ
  3. Select Open command prompt window here
  4. run any php command like php parameters
  1. 定位 C:\wamp\bin\php
  2. 按住 SHIFT 并用鼠标右键单击文件夹 phpX.Y.ZZ
  3. 选择 Open command prompt window here
  4. 运行任何 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”,它将起作用。我的工作得很好。