Composer provides dependencies management of PHP programming language, developed by Nilsadermann and JoddiBoganiano.
First if you had try to install & not succeed, then first remove composer directory from system, for that past following command in terminal :
sudo rm -r /usr/local/bin/composer
Step 1 : Download composer
Now download composer from its official website.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Step 2 : Install composer
If we want to run composer from everywhere inside out system, then we should install it globally. So need to install in following path : /usr/local/bin
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Step 3 : Test composer
After installation check all run smoothly or not by typing "composer" in terminal or if it nor run then use following command :
Step 4 : Run globally
To access composer from anywhere, need to move installed file in following path : /usr/local/bin/composer, by following command :
mv composer.phar /usr/local/bin/composer
Now, all done here, try to run from anywhere : "composer".