1
curl -sS https://getcomposer.org/installer | sudo php -- --install- dir=/usr/local/bin --filename=composer 

When I run the above command in terminal I got this this response:

Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The json extension is missing.
Install it or recompile php without --disable-json

The phar extension is missing.
Install it or recompile php without --disable-phar

The iconv OR mbstring extension is required and both are missing.
Install either of them or recompile php without --disable-iconv
karel
  • 110,292
  • 102
  • 269
  • 299
Supriya
  • 11
  • 1
  • 2
  • Isn't `sudo apt install composer` working? Or you need exactly [composer.phar](https://getcomposer.org/doc/00-intro.md#globally)? – pa4080 May 05 '17 at 08:15
  • Why don't you try composer locally https://getcomposer.org/doc/00-intro.md#locally – digiwizkid May 05 '17 at 08:24
  • @SpasSpasov the .phar extension stands for **ph**p **ar**chive indicating how the file package is formatted, not what's in the archive. – karel May 05 '17 at 08:27
  • @karel, I read about it and got it. Thank you for the direction. – pa4080 May 07 '17 at 09:08

1 Answers1

1

In Ubuntu 16.04 and later composer can be installed from the default Ubuntu repositories. Open the terminal and type:

sudo apt install composer  

This command will also install the required PHP and JSON dependency packages along with it. Composer dependency manager for PHP helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.

karel
  • 110,292
  • 102
  • 269
  • 299
  • This works but does not get the latest version. How would one get the latest version of Composer (I'm on 18.04 bionic)? – Jonathan Mar 15 '19 at 01:46
  • 1. Change directories using `cd` to the directory where you want to install the latest version of Composer. 2. Run this command to download composer.phar: `curl -sS https://getcomposer.org/installer | php` 3. If you want to use the new Composer that you installed globally instead of locally read the instructions in the 2nd section of [this answer](https://askubuntu.com/questions/820803/unable-to-download-composer/820805#820805). – karel Mar 15 '19 at 02:46