Thursday, August 18, 2016

Installing Composer in Mac


Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default it does not install anything globally. Thus, it is a dependency manager. It does however support a "global" project for convenience via the global command.

System Requirements

Composer requires PHP 5.3.2+ to run. A few sensitive php settings and compile flags are also required, but when using the installer you will be warned about any incompatibilities.

To install packages from sources instead of simple zip archives, you will need git, svn, fossil or hg depending on how the package is version-controlled.

Composer is multi-platform and we strive to make it run equally well on Windows, Linux and OSX.

How to install composer in Mac

1. Download composer. Run this command in your Terminal
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"

2. Move composer.phar to /usr/local/bin by running this command.
sudo mv composer.phar /usr/local/bin/composer

If you receive the error "/usr/local/bin/composer: No such file or directory" then you must create the directory manually before proceeding: sudo mkdir -p /usr/local/bin. Theb you can try to move composer again to /usr/local/bin folder.

That's all about Installing Composer in Mac. Thankyou very much for the visit, and see you next time in the next tutorial.

No comments:

Post a Comment