简体   繁体   中英

How to upgrade php version on Windows 10

I'm trying to get my Laravel project to work. But when I use composer update it says the following:

This package requires php >=5.6.4 but your PHP version (5.5.12) does not satisfy that requirement.

I'm using WAMP which runs php version 7.0.4 this is also confirmed in the browser if I echo the php version. But when I use php -v in the console it shows that I'm using PHP version 5.5.12 (cli).

I've searched a bit around on google and I found out that it uses my windows PHP version instead of my webserver's version. But I couldn't find out how to update my PHP version on Windows.

My PATH contents are as shown in the following image

在此处输入图片说明

You can uninstall composer, and while re-installing it will ask you to point at your PHP directory which is going to be C:\\wamp64\\bin\\php (usually) at that point you can choose which PHP version you would want to use. good luck.

在此处输入图片说明

This means you have yet another installation of PHP in your system. Check your Programs in Control Panel and remove such installation.

However, you can modify your PATH environment variable as well. Procedure

Just remove the path that points to any PHP installation directory.

Else, otherwise, if you are unsure about changing the PATH variable (which can lead to serious problems if not set well), you can just delete the directory that the PATH variable points to.... (I mean the PHP directory)

The totally better solution is to add the path of your PHP7 bin directory at the beginning of the PATH variable. You should also make available composer in this PHP7 bin directory.

Such as, replace the C:\\php in your path with C:\\wamp\\bin\\php7 or whatever the location of the PHP7 path is..

To update PHP on Windows 10.

You must put the folder of the new PHP version in the same folder as the old. You rename the old folder or you delete it, prefer rename the old folder, now you write in a terminal console

php - v

PHP automatically check for a new version

if you had installed before xampp/wampp and composer globally you might had added php to you environment path to call it where ever you want, and now you want that composer use the new xampp with php the you recently installed, so go to system>advance tab> environment variable> maybe in PATH then search if you have something like C:\\xampp\\php and edit to your new php location.

I had multiple versions off xampp for testing and composer globaly instaled for php 7.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM