Switch between multiple Composer versions

  • | 115 points

    I need to be able to switch between composer1 and composer2. Some of my projects don't work on composer2 due to them being very old and due to old dependencies.
    But for new projects, I wish to be able to use composer2.

    Right now, I've downloaded and extracted composer2 in a seperate folder and created an alias for it and am running it with

    composer2 install

    But I wish to know if laragon provides a way to switch composers easily like we can switch php?

  • | 15689 points

    @arun07as I can think of a couple of ways to do this.

    If you want a specific composer version per project you can install the composer.phar to the project root, then use it with a PHP suffix e.g. composer install would be:

    php composer.phar install

    Another way is to upgrade (or downgrade) the global composer to a specific version.

    Downgrade to version 1:

    composer self-update --1

    Upgrade to version 2:

    composer self-update --2

  • | 434 points

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

Log in to reply

Looks like your connection to Laragon was lost, please wait while we try to reconnect.