如何更改作曲家使用的 PHP 版本 [英] How to change PHP version used by composer

查看:26
本文介绍了如何更改作曲家使用的 PHP 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的机器上使用另一个 php 版本,而不是使用 WAMP (安装了 2 个 PHP 版本).

I want to use another php version on my machine than the one already installed using WAMP (2 PHP version installed).

  • 安装的composer使用PHP 5.6
  • 一个新项目需要 PHP7.0.

每当我从 WAMP 的控制面板中选择 PHP 7 然后运行 ​​php -v 它仍然打印 PHP5.6 (CLI)... 而不是 PHP7.

Whenever I choose PHP 7 from the control panel of WAMP and then run php -v it still printing PHP5.6 (CLI)... instead of PHP7.

如何在不重新安装 composer 的情况下使用 PHP7?

How can I use PHP7 without reinstalling the composer again?

推荐答案

不用卸载composer就可以更改php版本,按照以下步骤:

You can change php version of composer without uninstalling it, follow these steps :

  1. 在 cortana 中搜索系统环境变量.
  2. 点击环境变量"按钮.
  3. 在系统变量"下选择路径并点击编辑,您将看到一个类似C:wampinphpphp5.6.13"的条目.
  4. 只需将其更改为位于您的 wamp/bin/php7.1.9 的 php 的文件夹名称,这里 php7.1.9 是文件夹名称.
  5. 将 php5.6.13 替换为 bin7.1.9,它看起来像C:wampinphpphp7.1.9",只需在所有框上单击确定即可.
  6. 你已经完成了.
  7. 为了验证,首先关闭所有的cmd窗口,然后打开cmd并输入php -v,回车,你应该会看到php7.1.9.
  8. 如果您没有看到 php 版本的变化,而只是重新启动您的电脑并在 cmd 中再次运行 php -v ,它将起作用.
  1. Search for system environment variables in cortana.
  2. Click on the button "Environment variables".
  3. Under "System variables" select path and click on edit, you will see one entry like this "C:wampinphpphp5.6.13".
  4. Just change this to the folder name of the php located at your wamp/bin/php7.1.9, here php7.1.9 is folder name.
  5. Replace php5.6.13 with bin7.1.9, it will look like these "C:wampinphpphp7.1.9", just click ok on all the boxes.
  6. You are done.
  7. To verify, first close all the cmd windows, than open cmd and type php -v, press enter and you should see php7.1.9.
  8. If you don't see change in php version than just restart your pc and run php -v again in cmd , it will work.

这篇关于如何更改作曲家使用的 PHP 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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