How to Install Composer on Mac OS

How to install composer on Mac OS.

What is Composer?

PHP Composer is a cross-platform dependency manager that allows you to manage package dependency in your project.

In my previous article, I have explained PHP Composer – how to manage package dependency in PHP through composer.

How to Install Composer on Mac OS

How to Install Composer on Mac OS

Subscribe Our Tutorials

Get Latest Updates on Facebook

How to Install Composer on Mac OS

To install composer in your Mac os, execute the following commands.

The installer provided by composer check few PHP settings. If everything seems ok then it will download composer.phar in your working directory.PHAR stands for PHP archive, it’s an archive format for PHP which can be run on the command line, amongst other things.

NOTE: PHP Composer Installation Error

In some cases, you might get following error. To resolve this error open your php.ini file and enter this line (detect_unicode = Off) at the end of file.

We have successfully installed composer in our mac machine. To access composer globally, let’s move it to /usr/local/bin directory.

Now composer.phar is moved to /usr/local/bin directory. Let’s create an alias in .bash_profile file.

If you are using Z shell then create this alias in .zshrc file. After that reload your bash_profile by using command source ~/.bash_profile.

Linux commands with examples

Now everything is done to check whether composer is installed successfully or not type composer in your terminal. If it installed successfully then you get following output.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , . Bookmark the permalink.