Composer is a PHP package manager with the purpose of handling all your project dependencies leveraging the great autoloading feature available in PHP.

Modern PHP Projects are developed following Object Oriented Programming Best Practices and one of this is to encapsulate the code into classes, having each class in its own file (...read more on this topics).

These files are organized in folders in such way that  the Symfony project installed here looks like:

 

 

Install composer 2 in Linux / Unix / macOS machines.

Open a SSH console to the machine where you want composer to be installed.

You need to have PHP installed first.

If you want composer 2 to be available in project/directory/path

cd /project/directory/path

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');"

 

If you want composer 2 to be available in any directory in the machine:

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

This way you may call composer from everywhere but using sudo. If You don't want to use sudo, you may want to install composer 2 only for your user:

mv composer.phar ~/.local/bin/composer

 

 

Install composer 2 in Microsoft's Windows machines.

Just download the executable from here

Then run the .exe file. This .exe file will set the PATH for you so you can call composer 2 from everywhere in this machine.