Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Install Composer On Mac Globally & Locally

Configuring Composer on a Mac device is somewhat trivial, this article aims to provide a step by step guide on how to install and use composer on Mac. The guide will start from complete scratch and walk through each step to completely install the Composer package managing tool.

  • Install Composer Globally On Mac
  • Install Composer Locally On Mac

Installing Composer On Mac Globally

Installing Composer in global form is much more efficient if you intend to develop many applications on your device. Let’s go ahead and Install Composer without the need for composer.phar being present in every project directory.

Step 1

Open a new Terminal Command line and execute the following command to download the composer.phar file.

curl -sS https://getcomposer.org/installer | php

Step 2

Next we need to move the composer.phar file into the mac device’s bin directory under a newly created sub-directory of composer.

Run the following two commands in sequential order.

mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

And that is it, the global install is complete.

Now we’ve completed steps 1 and 2, Composer is completely Global on your device, meaning you can call the tool in any directory.

Try running the following command in the terminal –

composer

You should now see something like the following output in the terminal

Installing Composer On Mac Locally

Step 1

Open the Terminal command line and proceed to navigate to your project folder with a similar command like below –

cd /Applications/XAMPP/htdocs/myProject

Step 2

Execute the following command which should yield a blank response.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Step 3

Execute the following three commands in sequential order

php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

And that is it, the local install is complete.

Now we’ve run steps 1 to 3, there is a new file present in the project directory, composer.phar, this is essentially the composer engine.

When we want to use Composer we must call the composer.phar file within the project directory and proceed to execute further commands on it like require etc.

Test the installation by running the following command, making sure you are currently in the project directory within the terminal.

php composer.phar

You should see something like the following output in the terminal

The post How To Install Composer On Mac Globally & Locally appeared first on Code Wall.



This post first appeared on Code Wall - Web Development & Programming, please read the originial post: here

Share the post

How To Install Composer On Mac Globally & Locally

×

Subscribe to Code Wall - Web Development & Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×