In this tutorial I am going to provide steps on how to uninstall and install composer on ubuntu server.
of-course you can use it into your local ubuntu operating system as well.
Table of Contents
Root cause of reinstalling composer:
The reason I am writing this tutorial because, I had an application running on production server for about 6-8 months which is using Laravel framework and hosted on VPS server with Ubuntu 16.04 installed .
Today I wanted to update Laravel application dependencies with composer update command, but for somehow I get exception showing below it could not allow me to update.
[ErrorException]
“continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”?
I did some research and find out that the issue is with current installed composer and the suggestion was to update it to latest on.
Good so far?
So I decided to update the composer, I know that it is easy we can just execute composer self-update command and we are done, but hold on we are done yet.
I had next issue, composer could not allow me to do self update, it was also giving me following Error Exception, here is how:
composer self-update
Here is the exception I got:
[RuntimeException]
SHA384 is not supported by your openssl extension, could not verify the phar file integrity
So finally I figured out the issue behind all of this, it is with the current installed version of composer and it needs to be updated to execute composer command.
Let’s see how we can do that:
Uninstall composer:
Un-installing composer is really easy you just have remove the composer.phar
or composer file wherever it is located.
For me it was located inside user bin folder, so I deleted it using command below:
rm /usr/local/bin/composer
If you are not sure about location of composer file, then you can use following command to find out:
which composer
Install Composer:
There are two ways installing composer first is by visiting https://getcomposer.org/download/ site and using the instruction and second is using the curl and here I am going to use the second way which I always prefer to use.
Use bellow command to download the latest composer.phar
installer file:
curl -sS https://getcomposer.org/installer | sudo php
Move composer.phar
to user bin directory to make it global, so we can access it from any project folder.
sudo mv composer.phar /usr/local/bin/composer
We done re-installing composer, if you type composer into your terminal you will see composer will show you the current version installed with all help option and available command:
composer
Feel free to comment your questions or suggestions related to tutorial using comment box below.
work,, thanks
thankx. this is realy helpfull
Nice! Thx.
TYVM!!!