本文介绍了如何使用作曲家在两个不同的PHP版本之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此有很多研究,但没有发现任何可以解决我的问题的方法.我现在正在使用laravel5.1开发一个项目,并且正在使用PHP5.6版本,但是我也想安装新的laravel版本,该版本是L5.5,但是最低PHP要求是PHP7.0,因此选择我安装的composer中的5.6版本的PHP.

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.

如何在不一次又一次地重新安装作曲家的情况下切换这两个版本的PHP?因此,如果我使用Laravel5.1,可以将作曲家与PHP5.6一起使用,否则,我可以将Laravel5.5PHP7版本一起使用.

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.

注意:
我正在使用具有PHP5.6& PHP7可供使用.

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

推荐答案

创建一个Windows批处理文件,该文件使用php7二进制文件调用composer.phar文件.我们将其命名为composer7.bat:

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" %*

将文件与最初安装的composer.bat文件一起保存,我的文件位于C:\ ProgramData \ ComposerSetup \ bin \目录中.

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

现在使用新命令调用php7作曲家:

Now call the php7 composer with the new command:

composer7 require ...

这篇关于如何使用作曲家在两个不同的PHP版本之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:37