Upgrade to Composer 2.x
-
I have laragon installed, but I have been unable to upgrade to the 2.x version.
What are the steps that I should follow for Laragon on windows to upgrade my composer?
-
@pramanikriju : What the steps did you do to upgrade composer?
-
First I tried the official method to run the windows setup file, but laragon has it's own composer in the 'bin' directory.
So I replaced the composer.phar file there and followed the steps here
Then I restarted laragon, but composer -V still gives me 1.x
-
The upgrade process is based on getcomposer.org/download/
You first need to change your directory to C:\laragon\bin\composer Or in explorer navigate to C:\laragon\bin\composer and open Terminal
cd C:\laragon\bin\composer
Run
composer -V
to get the current version (e.g.):C:\laragon\bin\composer λ composer -V Composer version 1.10.7 2020-06-03 10:03:56
Then follow the steps from getcomposer.org/download/
Note: There steps are for composer v2.0.3, the hash_file will be different for newer versions! Check the link above for the latest version.
C:\laragon\bin\composer λ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" C:\laragon\bin\composer λ php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" Installer verified C:\laragon\bin\composer λ php composer-setup.php All settings correct for using Composer Downloading... Composer (version 2.0.3) successfully installed to: C:\laragon\bin\composer\composer.phar Use it: php composer.phar C:\laragon\bin\composer λ php -r "unlink('composer-setup.php');"
Check the version of composer by running
composer -V
C:\laragon\bin\composer λ composer -V The "hirak/prestissimo" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option. The "hirak/prestissimo" plugin (installed globally) was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option. Composer version 2.0.3 2020-10-28 15:50:55
If you have a message about "hirak/prestissimo" plugin, like me, you can uninstall it:
composer global remove hirak/prestissimo
(e.g.):λ composer global remove hirak/prestissimo Changed current directory to C:/Users/Michael/AppData/Roaming/Composer The "hirak/prestissimo" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option. ./composer.json has been updated The "hirak/prestissimo" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option. Running composer update hirak/prestissimo Loading composer repositories with package information Updating dependencies Lock file operations: 0 installs, 0 updates, 1 removal - Removing hirak/prestissimo (0.3.10) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 0 installs, 0 updates, 1 removal - Removing hirak/prestissimo (0.3.10) Generating autoload files 11 packages you are using are looking for funding. Use the `composer fund` command to find out more!
Check the version of composer by running composer -V
C:\laragon\bin\composer λ composer -V Composer version 2.0.3 2020-10-28 15:50:55
-
So the steps work to upgrade my composer version to 2.x
But then, when I switch directories to any of my existing projects under 'www' and type
C:\laragon\www\project (master) λ composer -V Composer 1.10.8 2020-06-24 21:23:30
Whereas the composer folder in bin is updated to 2.x
C:\laragon\bin\composer λ composer -V Composer version 2.0.4 2020-10-30 22:39:11
So how will I know which composer file is being used in the project directory and how do I update those specifically?
-
@pramanikriju My guess is you have Composer installed globally.
- See this OS question
- Change
COMPOSER_HOME
to c:\laragon\bin\composer.
- Change
- You can also check control panel > programs and remove Composer.
- Finally check you have added Laragon to PATH.
- Menu > Tools > Path > Manage Path, then if required Add Lagaon to Path.
- Log off and back on after changing the Path.
- See this OS question
-
I have successfully upgraded my composer to 2.x using these methods
-
Find where your composer file is
which composer
-
For me, it was in
/c/Users/USERNAME/AppData/Roaming/Composer/vendor/bin/composer
-
Open a terminal in that directory
-
follow the steps here - Installastion Steps
-
composer -V
should now return 2.x
-
-
I think the next version of laragon came with composer 2, Im looking forward for that one!!! 👍
-
-
composer selfupdate
does the trick .-.
-