To quickly install Composer in the current directory, run the following script in your terminal.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

This installer script will simply check php.ini settings, and warn you if the installation is incorrect, and then download the latest composer.phar in the current directory.

Most likely, you want to move the composer.phar into a directory on your PATH, so you can simply call composer from any directory (Global install),

To move your composer to the path use the below command.

sudo mv composer.phar /usr/local/bin/composer

Composer Version Change

Using below self-update command and you can change the composer version at any time.

You have to give the composer version correctly, In my case i am changin my composer version to 2.3.5 see the below command for your reference.

composer self-update 2.3.5

Leave a Reply

Your email address will not be published. Required fields are marked *