How to switch between two different php version wi

2019-05-27 03:44发布

I've got a lot of research about it but I found nothing that can help my problem. I'm developing a project for now using laravel5.1 and I'm using PHP5.6 version, however I also want to install the new laravel version which is L5.5 but the minimum PHP requirement is PHP7.0 and I chose the 5.6 version of PHP in my installed composer.

How can I switch this two versions of PHP without reinstalling the composer again and again? So if I work with Laravel5.1 I can use the composer with PHP5.6, otherwise I use Laravel5.5 with PHP7 version.

Note:
I'm using WAMP Server that has PHP5.6 & PHP7 available to use.

1条回答
倾城 Initia
2楼-- · 2019-05-27 04:05

Create a Windows batch file that calls the composer.phar file using the php7 binary. Let's call the file composer7.bat:

@echo OFF
:: in case DelayedExpansion is on and a path contains ! 
setlocal DISABLEDELAYEDEXPANSION
c:\path\to\php7\directory\php.exe "%~dp0composer.phar" %*

Save the file along with the originally installed composer.bat file, mine is located in C:\ProgramData\ComposerSetup\bin\ directory.

Now call the php7 composer with the new command:

composer7 require ...
查看更多
登录 后发表回答