PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 1, 2022

[FIXED] How to switch between two different php version with composer

 March 01, 2022     composer-php, laravel-5, php     No comments   

Issue

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.


Solution

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 ...


Answered By - Scriptonomy
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing