How we can use composer 1 & composer 2 both in the same machine. As a developer we worked on the multiple project in the same machine and situation comes where project 1 required composer 1 and project 2 required compower version 2.
-
Welcome to SO. In this case you better ask your question first like `How to keep composer 1 & 2 both in same machine?` and then add your answer and accept it. – endo64 Dec 13 '20 at 12:24
-
thanks for the suggestion, i will follow the same. – Parveen Dec 14 '20 at 13:08
2 Answers
This is what I used to have composer 1 & 2 both in the same machine. I am hoping this will helpful for someone, who want to use composer 1 & 2 both as separate command
Keep Composer 1 & 2 as separate command
Setup Composer 1:
Copy the current composer directory to new
cp `which composer` /usr/local/bin/composer1
Update it to version 1:
composer1 self-update --1
Upgrade to Composer 2 & create alias:
Update composer to version 2
composer self-update --2
Create symlink for composer2 (optional)
ln -s `which composer` /usr/local/bin/composer2
Now you can use composer
or composer2
command for the project dependent on composer 2 and composer1
command for the project have dependency on composer 1.
Note: you might required to use sudo before the command
for windows do the following steps:
one -> (create
composer1
directory in C:\composer_path)two -> (copy three file in
composer
directory tocomposer1
directory)three -> (set path
composer1
toenvironment variable
)four -> (run
composer1 self-update --1
in cmd) because Convert to version 1.0.0five -> (test versions composer)
and Done! ^_^
you can see two version of composer installed in one windows system.
reference : How to install two composer in one windows system?

- 23
- 1
- 8
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33727956) – ahuemmer Feb 01 '23 at 08:27
-
2.5.1 is _not_ the composer LTS version, the LTS version is on the 2.2 channel. And honestly I see no need to duplicate your own answer as the comlete Q&A is here: https://stackoverflow.com/a/75268693/367456 and also prominently linked as related question already. Please remove it and improve the original answer. – hakre Feb 02 '23 at 10:56