Categories: LaravelLinuxUbuntuVPS

How to uninstall and install composer in ubuntu?

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.

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.

“continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”?

Composer Update Error Exception

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:

SHA384 is not supported by your openssl extension, could not verify the phar file integrity

Composer self-update error exception

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 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 | sudo php
Download composer installer

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:

Check Current installed composer version details

Feel free to comment your questions of suggestions related to tutorial using comment box below.

Yogesh Koli

Software engineer & Blogger lives in India, has 6+ years of experience working with the front-end and back-end web app development.

Recent Posts

Complete guide of using Laravel 6 Eloquent Subquery Enhancements

Learn How to use laravel frameworks new improved feature called Eloquent Subquery and get example…

8 months ago

3 Useful examples of using Array Map function in PHP – Best Practices

Learn how to use php array map function with easy and essential tutorial to modify…

8 months ago

Working with PHP Array Filter Function – Best Practices

Learn how to use php array filter function with easy and essential tutorial to filter…

8 months ago

How to add Access Modifiers with Constructor Parameters in TypeScript

Want to know how to refactor your Typescript class, Learn here utilising Typescript of the…

8 months ago

What is Access Modifiers and how to use Access Modifiers in TypeScript ?

What is Access Modifiers in typescript, how to use Access Modifiers, when to use them,…

9 months ago

Top 10 Super Useful Packages to Improve Laravel applications in 2019

This tutorial provide ultimate list of package those are top 10 on packagist and super…

9 months ago