I am currently running Wampserver with multiple PHP versions (5.3.8, 5.4.3). Wampserver easily allows you to switch back and forth between the php version you want apache to use. However, I'm having trouble dealing with multiple versions from the CLI. I have projects that require the command line, but some are compatible with php5.4, while some are not. Show Is there a way to create some type of "alias" in Windows that allows me to specify which version of PHP to use on the command line .. I.E: "php54 cache:clear", "php53 cache:clear" ?? Thanks! asked Mar 25, 2013 at 14:32
4 I am doing something like below. ex. I have two php version , PHP 5.6 and PHP 7.3 I have wamp environment so I have done as below so I have copied D:\wamp\bin\php\php7.3.6\php.exe to D:\wamp\bin\php\php7.3.6\php7.exe and I have copied D:\wamp\bin\php\php5.6\php.exe to D:\wamp\bin\php\php5.6\php56.exe Then I have added both to environment variable path like below. now you need reopen the cmd and you can use command something like below
You can also run command refreshenv to reload environment variables in opened cmd. If you want change default php version, you can move paths as below. ex if you want php 7.0.23 as default instead of php 7.3.6 see screenshot for example In above screenshot I have move php 7.0.23 above the all other php verions (php 7.3.6 and php 5.6.31). I hope this will help. answered Oct 9, 2019 at 13:27
Its quite simple really. Create yourself a batch file to add php to the path, place that file in one of the folders that is currently on your PATH so you can run it from anywhere. Then whenever you are in any folder that has CLI scripts in it run the batch file Example batch file: Lets call it PHPPATH.CMD
Now if you want to use another version of the PHP CLI just change the batch file or if you are feeling clever make the batch file accept a paramter so you can specify the version of php you want on the path. answered Apr 27, 2013 at 1:35
RiggsFollyRiggsFolly 91.2k20 gold badges101 silver badges145 bronze badges If you are able to do so, just create aliases: alias 'php56'='/Path/To/php5.6/bin/php'; alias 'php55'='/Path/To/php5.5/bin/php'; If not, create links in a seperate directory that point to the binaries. php56 is a link to /Path/To/php5.6/bin/php php55 is a link to /Path/To/php5.5/bin/php put these into /Seperate/Path/ and add '/Seperate/Path/' to %PATH% Hope this helps answered Nov 27, 2018 at 14:48
0 I've searched how to do it really easily without changing the environment variable path with the command line (because it's character limited) and find this solution (only on windows 10) : in your environment variable path , change then create a junction between your php version directory and then you can use this batch file
now you can run your batch file in your cmd and don't even have to restart it after.
Rohit 2,3621 gold badge17 silver badges32 bronze badges answered Aug 24, 2020 at 17:31
How can I run two PHP versions on Windows?In this article, we will learn about running two versions of PHP on the same Apache server.. After changing the port click on save and exit.. Now go to the extra folder.. Changes to be done in the ssl CONF file.. Change the Listen 443 to 444.. How do I switch between PHP versions?Upgrading or Downgrading PHP Versions. Ensure the php packages for the version you want are installed.. Update any configuration for that PHP version.. Update your web server configuration to point to the correct PHP version.. Point PHP CLI to the correct PHP version.. Restart your web server and php-fpm.. How do I run multiple versions of PHP?Install several PHP versions using PHPBrew. Install Apache web server with FastCGI module. Create separate FastCGI script for each PHP version. Map appropriate FastCGI script for web application execution on virtual host level.
Can I run several versions of PHP at the same time?Yes we can run several versions of php. To do that we must have to check the INSTALL file, if it is included in PHP source distribution.
|