Wednesday, September 16, 2015

What is Composer? Why do we need Composer for Php development?

What is Composer? Why do we need Composer for Php development?

If you are doing development in Php then you might always face a issue whenever you are handling with 3rd party libraries. Integration and configurations of 3rd party library is always a headache in Php. For configuration you will have to read the documentation of 3rd party library. It resolve the dependency of a package.

But this has been easy after introduction of Composer.

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
Composer is just a command line tool which helps you to manage dependency for Php. Remember it is not a package manager tool. It is very easy to learn.

Composer helps you to solve following problems : 

  • It resolves the dependency of a package : Suppose you are installing one package for Mongo DB and you do not know the dependency of this package. If you use Composer it will resolve the dependency and install it.
  • Command line tool : Good for developers. You just have to configure a JSON file, run the command and you are done. Rest of the things will be handled by Composer. Ex: Suppose you want to install Monolog in your project then configure the composer.json
{
    "require": {
        "monolog/monolog": "1.2.*"
    }
}
  • Version : You do not have to worry about the version of library. You just provide the version number or provide *. If you are providing version number then it will install that particular version otherwise the latest version.
System Requirement for Composer:  

You need 5.3.0+ version of Php.


No comments:

Post a Comment