Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Composer in Windows 10

I am using Composer for my PHP project. I am new to Composer. Now when I update my dependencies using composer update command, it is saying that my Composer version is too old and ask me to update. So I tried as below. But all failed.

My composer.phar file is in C:/ProgramData/ComposerSetup/bin/composer.phar

I opened terminal and tried

composer.phar update  php composer.phar update  composer C:/ProgramData/ComposerSetup/bin/composer.phar update  php composer C:/ProgramData/ComposerSetup/bin/composer.phar update 

When I run composer-self-update, error as in screenshot.

enter image description here

All command failed. I am using XAMPP. There is no composer.phar file in xampp/php folder as well. How can I update Composer in Windows 10?

like image 998
Wai Yan Hein Avatar asked Apr 22 '16 06:04

Wai Yan Hein


People also ask

How do I update the latest version of composer?

update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.

What is composer update command?

The “composer update” command gets the latest versions of the dependencies required by the project and then update the “composer. lock” file. compose update. The above will resolve all the dependencies in our project and write the exact versions into composer. lock file.


2 Answers

Try

composer self-update 

If this doesn't work check your PATH variable, if it's not there try searching composer.bat in windows and add it to your PATH variable. Normally, its in following path.

C:\ProgramData\ComposerSetup\bin

like image 114
rishal Avatar answered Sep 29 '22 09:09

rishal


Windows 10 update for Composer still works (end of 2020, pre version 2) with:

Follow This below Image: enter image description here

composer self-update --1 it will be updated from 1.x

composer self-update --2 it will be updated from 2.x and from 1.x

composer self-update --rollback If you need to rollback to your previous version

composer -V For check your composer version

composer self-update:

If you run composer self-update from 1.x, it will warn you that a new stable major version of Composer is available, and you can use composer self-update --2 to migrate to it.

So run composer self-update --2

How easy is it to upgrade?

  • Composer 2.0 still supports PHP 5.3 and above, much like Composer 1.x
  • composer.lock files are interoperable between versions, so you can upgrade to 2.0 and roll back easily if needed.
  • Most commands and arguments remain the same, and largely what you know about Composer remains true in 2.0.
like image 23
Haron Avatar answered Sep 29 '22 10:09

Haron