在WAMP PHP Google+项目中安装Composer,无法识别PHP [英] Installing Composer in WAMP PHP Google+ Project, PHP is not recognised

查看:120
本文介绍了在WAMP PHP Google+项目中安装Composer,无法识别PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注此PHP Google+教程,并且我正在尝试在自己的计算机上安装composer WAMP目录

I am following this PHP Google+ tutorial and I am trying to install composer in my WAMP directory

C:\wamp\www\gplus-quickstart-php>curl -s https://getcomposer.org/installer | php

但我遇到此错误

php未被识别为内部或外部命令可操作的
程序或批处理文件。

'php' is not recognized as an internal or external command operable program or batch file.

如何解决此问题?我已经安装了PHP(通过WAMP Server)。

How do I resolve this problem? I already have PHP installed (via WAMP Server). Do I have to install PHP in my computer as well?

推荐答案

好,您需要在这里做几件事。

Ok a couple of things you need to do here.

第一个窗口没有像unix这样的curl处理器,因此您需要使用其他选项来安装Composer

First windows does not have a curl processor like unix so you need to use the other option for installing Composer

php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

要使此功能正常运行,您需要将php.exe处理器放在您的路径上,因此您需要2这里的选项。将 c:\wamp\bin\php\phpx.yz 文件夹添加到PATH 这是WAMPServer的错误选择 ,因为您可以安装多个版本的PHP,并且在激活另一个版本时,PATH仍将指向旧版本。或者我更喜欢的选项是为自己编写一个.cmd文件,它将像这样

For this to work you need the php.exe processor to be on your path, so you have 2 options here. Either add the c:\wamp\bin\php\phpx.y.z folder to your PATH thats the bad option for WAMPServer as you can have more than one version of PHP installed and when you activate another version your PATH will still be pointing at the Old version. Or my prefered option write yourself a little .cmd file which will do it for you like this

filename = addphp.cmd

filename = addphp.cmd

PATH=%PATH%;c:\wamp\bin\php\phpx.y.z

将此文件放在路径中已注册的文件夹中,以便您可以在命令窗口中的任何位置运行它。

Put this file in a folder already registered on your path so you can run it from anywhere in a command window.

现在,您将必须编辑\wamp\bin\php\phpx.yz\php.ini文件。这与通过Apache Web服务器运行的php代码所使用的类似,但仅由PHP CLI(命令行解释器)使用。

Now you will have to edit the \wamp\bin\php\phpx.y.z\php.ini file. This is similiar to the one used by php code run through the Apache web server but is only used by the PHP CLI (Command Line Interpreter)

确保扩展名php_curl为未注释或上面的行将不起作用,即删除; 注释符号

Make sure the extension php_curl is uncommented or the above line wont work i.e. remove the ; comment symbol

extension=php_curl.dll

现在运行命令窗口,将cd插入要安装作曲家的文件夹并运行上述命令,然后按照安装说明

So now run a command window, cd into the folder that you want composer installed into and run the command above, then follow the rest of the install instructions on Install instructions

这篇关于在WAMP PHP Google+项目中安装Composer,无法识别PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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