Composer is a tool for managing dependencies in PHP. It allows you to declare through simple notations in a text file which libraries your project needs and automatically installs them for you.
Composer is not just a package manager. Yes, it handles packages or libraries, but he manages all based design, installing these dependencies in a directory (e.g. vendor) within your application. Composer is not a package manager. 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 will never install anything globally. Thus, it is a dependency manager. This idea is not new and Composer is strongly inspired by node’s npm and ruby’s bundler. But there has not been such a tool for PHP. The problem that Composer solves is this: a) You have a project that depends on a number of libraries. b) Some of those libraries depend on other libraries . c) You declare the things you depend on d) Composer finds out which versions of which packages need to be installed, and installs them (meaning it downloads them into your project).
How to Install Composer
You can install Composer locally (in your current working directory; though this is no longer recommended) or globally (e.g. /usr/local/bin). Let’s assume you want to install Composer locally. From your project’s root directory:
curl -s https://getcomposer.org/installer | php
This will download composer.phar (a PHP binary archive). You can run this with php to manage your project dependencies. Do you want to know more about how to install it? Click here for the full documentation.
Is it like Pear?
PEAR requires each package to have a specific structure, which means that the author of the package must prepare it for usage with PEAR. Using a project which was not prepared to work with PEAR is not possible. PEAR installs packages globally, which means after installing them once they are available to all projects on that server. Whereas Composer install packages per project.