Is There Way to Use Two PHP Versions in Xampp

How to run multiple PHP version with XAMPP?

Try these steps:

  1. Stop LAMP if running.

Download libphp7.so if you don't have

https://github.com/prashant-techindustan/php7module_library/blob/master/libphp7.so


  1. Edit /opt/lampp/etc/extra/httpd-xampp.conf (Comment out one of the following which is not needed):

    LoadModule php5_module modules/libphp5.so

    LoadModule php7_module modules/libphp7.so

  2. Start LAMP

Multiple Different PHP version is not working

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


Related Topics



Leave a reply



Submit