First things first, we need to install composer if you haven't already. For more information check out composer download page. I am using a Mac therefore the commands shown are for Mac OS. For windows, its a lot easier just download the installer (Composer-Setup.exe) and double click.
Download composer via curl. I usually run this command from within my home ~/ directory but you can do it form any directory.
curl -sS https://getcomposer.org/installer | php
Running the above command will create a composer.phar in the current directory. You can now use composer like so.
php composer.phar install
Installing Composer Globally
To run composer form any directory you need to install it globally. From within the directory where the composer.phar file was downloaded, run the following comand.
mv composer.phar /usr/local/bin/composer
Add alias for bash ~/.bash_profile
To add an alias open your bash_profile or zshrc and add alias at the end of the file.
sudo vi ~/.bash_profile alias composer="php /usr/local/bin/composer"
Add alias for oh my zsh ~/.zshrc
sudo vi ~/.zshrc alias composer="php /usr/local/bin/composer"
Thats it! you should now be able to run composer like so composer init and composer install. Remember to restart your shell before running these commands.