If you use npm for Node, pypi for Python, or bundler for ruby, you will want to use composer, if you still use PHP.

To get started, install as per instruction.

For Mac, it will be a few brew commands.

brew tap josegonzalez/homebrew-php
brew install josegonzalez/php/composer

If you have some errors, you might need to brew install php53-intl, brew update and brew doctor. I have to do that for some weird errors.

Next, prepare a basic composer.json in your root directory. The below json is an example of a project that requires monolog.

    "require": {
        "monolog/monolog": "1.0.*"

Install the library and it’s dependencies (monolog in this example).

curl -sS | php
php composer.phar install

A vendor directory will be created and it contains all the libraries. You can start using the libraries as per normal.

Or use autoload.

For developers with library/SDK to share..

If you have your library/SDK and you want to upload to composer repository, create a composer.json in your project root directory.

Here’s one for reference.

Then go to packagist, register an account, and point it to your repository.




Back to Home