Globally Composer 2 Installation
Complete guide to start Linux OS and install essential applications in Linux
You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH
, you can access it globally. On Unix systems you can even make it executable and invoke it without directly using the php
interpreter.
Remove Composer:
Please remove composer using following command if already installed composer
sudo apt-get remove composer
Download:
Create a directory and open terminal, execute following command
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
You will see a file will be created in this folder.
Move This File
After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path:
mv composer.phar /usr/local/bin/composer
Check
Now run composer
in order to run Composer instead of php composer.phar
.
saidul@saidul-Inspiron-5502:~/Downloads/soft$ composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.2.4 2022-01-08 12:30:42 ... ...
or execute only
composer --version
Output like:
saidul@saidul-Inspiron-5502:~/Downloads/soft$ composer --version Composer version 2.2.4 2022-01-08 12:30:42