install composer global code example
Example 1: how to install composer macos
Open a terminal and navigate to your user directory, ie cd /User/<USER_NAME>/
Run this command shown below to download Composer. This will create a Phar (PHP Archive) file called
composer.phar:
curl -sS https://getcomposer.org/installer | php
Now we move
composer.phar file to a directory
sudo mv composer.phar /usr/local/bin/
We want to run Composer with having to be root al the time, so we need to change the permissions:
sudo chmod 755 /usr/local/bin/composer.phar
Next, we need to let Bash know where to execute Composer:
nano ~/.bash_profile
Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
and then run this command:
source ~/.bash_profile
Finally, run:
composer -v
Example 2: php composer update
php composer.phar update
Example 3: composer mac
php composer-setup.php --install-dir=bin --filename=composer
Example 4: where do you install composer
// Adding permissions after installing Composer on Mac OSX
sudo chmod 755 /usr/local/bin/composer.phar
Example 5: how to install composer windows
why is it so hard to install composer every time it's a struggle