如何正确设置PHP环境变量来运行Git Bash中的命令 [英] How to properly set PHP environment variable to run commands in Git Bash

查看:494
本文介绍了如何正确设置PHP环境变量来运行Git Bash中的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在整个网站中有一些类似的问题,但是他们都没有给我我正在寻找的答案。

There are a few similar questions as this throughout the site, but none of them are giving me the answer I'm looking for.

我正在尝试要做的是在具有WAMP的Windows机器上通过Git Bash安装Composer。

我使用以下命令:

What I'm trying to do is install Composer via Git Bash on a Windows machine that has WAMP.

I'm using the following command:

curl -s http://getcomposer.org/installer | php

这不工作,因为'php'无法识别。所以我研究了这个问题,我意识到Windows不知道'php'是什么,我需要设置一个环境变量。

This is not working, as 'php' is not recognized. So I looked into the problem and I realized that Windows does not know what 'php' is, and I need to set an environment variable.

我进入环境变量对话并输入'php'作为变量,并将 C:\wamp\bin\php\php5.3.8 作为值。它是否正确?我应该将特定文件或目录作为一个整体定位吗?

I go into the environment variable dialogue and enter 'php' as the variable and C:\wamp\bin\php\php5.3.8 as the value. Is this correct? Should I be targeting a specific file or the directory as a whole?

这样做之后,我再次尝试该命令,并且失败,因为它仍然无法识别'php' 。我也尝试将文件路径直接输入到命令中,但是这也不行。

After doing this, I try the command again and it fails because it still does not recognize 'php'. I have also tried putting the file path into the command directly, but that didn't work either.

所以我很好奇我做错了什么。我的路径不正确吗?

So I am curious as to what I am doing incorrectly. Is my path incorrect?

推荐答案

添加路径到您的PATH变量应该修复。

Adding the path to your PATH variable should fix that.

右键单击我的电脑,转到高级设置,单击环境变量,然后编辑PATH系统变量。

Right click My Computer, go to advanced settings, click Environment Variables then edit the PATH system variable.

添加分号,然后添加路径到你的PHP二进制文件,即; C:\wamp\bin\php\php5.3.8

Add a semi-colon and then the path to your PHP binary, i.e. ";C:\wamp\bin\php\php5.3.8"

最后,重新启动Git Bash,以便它更新PATH变量。

Finally, restart the Git Bash so that it updates the PATH variable.

这篇关于如何正确设置PHP环境变量来运行Git Bash中的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆