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.
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!
Add a PHP Repository So you'll need to add the PHP repository in your system to install the multiple PHP versions. Once the repository is up-to-date, you can proceed to install multiple PHP versions.
For example, you can have PHP 5.4 for the site in public_html and then use PHP 5.2 in a subdirectory. You can use any combination of other PHP versions in any directory on the account.
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.
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
php56 -v
php7 -v
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With