To install composer successfully follow below given steps:
1.run these commands 1 by 1.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php
Once complete it will download composer.phar in current directory we need to move this file to
/usr/local/bin/composer
so run this command
sudo mv composer.phar /usr/local/bin/composer
If fails then it might give you error no directory exists for "/usr/local/bin/composer".
so we need to create this directory
in terminal run
cd ..
to get out of current directory, run it again and again to reach root directory.
once in root on running
ls
You should get "usr" folder.
if yes then
run this command
sudo mkdir /usr/local/bin
It will create the directory now run this
sudo mv composer.phar /usr/local/bin/composer
it should move "composer.phar" to targeted directory.
Note: you should have composer.phar in current directory to run "sudo mv composer.phar /usr/local/bin/composer" .it you do not have composer.phar then download again using 3 commands given on the top of this guide.