93

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
  • seems like your dns can't resolve getcomposer.org try updating your dns to 8.8.8.8, that might help – rishal Apr 22 '16 at 07:23
  • I tried compiser self-update 3 times. It is not working. But I closed terminal. Then do other works. After few minutes, I run "composer self-update" again. Now it is working. Why? I did not do any changes. :o – Wai Yan Hein Apr 22 '16 at 07:28
  • Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*) and [do the right thing](https://stackoverflow.com/posts/36786908/edit). Thanks in advance. – Peter Mortensen Apr 20 '23 at 20:48

5 Answers5

219

Try

composer self-update

If this doesn't work, check your PATH variable. If it's not there, try searching file composer.bat in Windows and add it to your PATH variable. Normally, it’s in the following path.

C:\ProgramData\ComposerSetup\bin

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
rishal
  • 3,230
  • 3
  • 22
  • 29
20

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 roll back 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.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Haron
  • 2,371
  • 20
  • 27
12

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

composer self-update

If you need to rollback to your previous version, you can do that with:

composer self-update --rollback
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
RustyNox
  • 409
  • 6
  • 7
5

Try.

php composer.phar self-update

'update' updates your dependencies, not Composer itself.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mubashar Abbas
  • 5,536
  • 4
  • 38
  • 49
1

Use

composer self-update --2

By default, the installer and composer self-update will download the latest stable version only. To programmatically install specific major versions you can use the --1 or --2 flag.

To go back to the previous version:

composer self-update --rollback

To check the current version

composer --version
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nishal K.R
  • 1,090
  • 11
  • 21