Composer Install Global Mac 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: install composer mac


curl -sS https://getcomposer.org/installer | php
php composer.phar install
mv composer.phar /usr/local/bin/composer
open -e ~/.zshrc
// or open -e ~/.bash_profile
alias composer="php /usr/local/bin/composer"

Example 3: upgrading composer globally on windows


php composer.phar self-update

Example 4: how to install composer on mac


/* 
Installing composer on mac... It's a pain!
Trust me on this one, first install homebrew then use home brew
to install composer. Your life will be much easier. ;)
*/

/* Run each of the commands below 1 by 1 */
/* Step 1 */
install homebrew
/* Step 2 */
brew install composer

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable