1

In my system I have 2 xampp servers installed.

In one xampp server php version is 5.6 and second xampp server php version is 7.3 .

In both server paths, only php 5.6 version is shown at command line.
Supported 7.3 is not working.
In both server path php 5.6 displayed.

So when I use Composer and Laravel always fetch php 5.6.

Please help me to solve this problem..

https://i.stack.imgur.com/ywNZa.png

Luiz Vaz
  • 1,669
  • 1
  • 19
  • 32
  • Changing PHP version on xampp does not affect on php cli version. You have to change php path on PATH. – Ts8060 Feb 27 '21 at 04:20
  • you can use [this link](https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10) to change path variable of your system – YICT IR Feb 27 '21 at 04:52
  • @Maitrik can you say if my answer solved you problem? – Luiz Vaz Feb 28 '21 at 21:36
  • @Luiz Vaz, at one time two environment variable is not working, either work PHP 7 variable else PHP 5 working. – Maitrik thakkar Mar 01 '21 at 08:42

1 Answers1

1

You are trying to run the CLI version of PHP.
So it's all about your PATH variable.

Windows looks for paths in PATH variable to know where are executables.

By the way, the php.exe it's inside c:\xampp\php directory. And, the 7.3 would be inside c:\xampp_7.3\php directory.

And of course, the PATH variable has something like PATH=c:\xampp\php;...
That's why 5.6 version is always picked.

Run command c:\set PATH and will show your settings like:

Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python38\Script
s\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windo
ws\System32\WindowsPowerShell\v1.0\;C:\xampp\php;...

To work, with changing PATH variable you need to move to you path where is composer.phar and composer.json and run:

c:\> cd \composer\file\
c:\composer\file> \xampp_7.3\php\php.exe composer.phar install

More information here: How to determine path to php.exe on Windows - search default paths

UPDATE:

As an alternative, you can set two environment variables and use them like below:

c:\> set PHP56="c:\xampp\php\php.exe"
c:\> set PHP73="c:\xampp_7.3\php\php.exe"

c:\> %PHP56% -v
PHP 5.6.40 (cli) (built: Jul  2 2019 15:10:36) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

c:\> %PHP73% -v
PHP 7.3.10 (cli) (built: Jul  2 2019 13:01:33) 
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Luiz Vaz
  • 1,669
  • 1
  • 19
  • 32