Linux

How to: install Composer on Linux Mint

21st February 2018 — by That IT Guy0

main

Linux

How to: install Composer on Linux Mint

21st February 2018 — by That IT Guy0

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

1: Composer does not have a .deb so a manual install is required. The first step, if you haven’t already, is installing PHP. This setup will fail if PHP is not installed. You can install PHP by running the following command:

sudo apt install php

2: While on your home folder on the terminal create a file for the script.

touch composer.sh

3: Open this file with your favorite editor, for this example, I’ve used nano.

nano composer.sh

4: Paste the following script in, save and exit nano.

EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")</pre>
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi

php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT

5: Make the script executable:

 sudo chmod +x composer.sh

6: Run the file:

sudo ./composer.sh

No output means it all went ok and it has created a composer.phar file in the same directory.

7: Now, move composer.phar to mkae it available anywhere within the system:

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

8: You can now test the install by invoking it anywhere by simply running the command

composer

That’s it, you’re done! You can visit the official website by clicking here.

composer