在 WAMP PHP Google+ 项目中安装 Composer,PHP 无法识别

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

问题描述

我正在关注 这个 PHP Google+ 教程,我正在尝试在我的WAMP目录

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

C:wampwwwgplus-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 服务器).我是否也必须在我的计算机上安装 PHP?

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.

第一个 windows 没有像 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:wampinphpphpx.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:wampinphpphpx.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

文件名 = addphp.cmd

filename = addphp.cmd

PATH=%PATH%;c:wampinphpphpx.y.z

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

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

现在您必须编辑 wampinphpphpx.y.zphp.ini 文件.这与通过 Apache Web 服务器运行的 php 代码使用的类似,但仅由 PHP CLI(命令行解释器)使用

Now you will have to edit the wampinphpphpx.y.zphp.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 到您要安装 composer 的文件夹并运行上面的命令,然后按照 安装说明

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 无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)