What is Composer?

What is Composer?

Composer is the dependency manager for PHP that allows you to add and manage script libraries and packages as dependencies in your project, in order to reduce development time and have the ability to take advantage of third-party code. By default, it does not install anything globally on your system (but can be done) but in the root of your project, typical in a vendor folder.

Composer uses Packagist.org as a main bundles’ provider. It provides files from repositories that users report on the site. Packagist.org hands over such features as, among others:  versioning or the integration with GitHub and/or bitbucket.

Why use composer

A good way to use composer is when you have a lot of dependencies and a good way to keep track of what version the dependencies is on is by looking at your composer.json file.

Composer is also a good fit if you work in teams and need to make sure you have the same versions of dependencies.
By running composer install composer will look at the composer.lock file instead that has been automatic generated when the first person run composer update.

It’s typical that deployment services like Forge and Envoyer running composer install to make sure it has the same version of dependencies as your local project has.

What is a composer.json file

composer.json file is where you put all your dependencies in, and it can look something like this

    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "laravel/socialite": "^2.0"
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"

require is where you put your “global” dependencies so your application can function. require-dev is only for local development.

I hope you like this post, Please feel free to comment below, suggestion and problems!

(Visited 8 times, 1 visits today)
Chandra Kumar

About the Author: Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of WebShouters.com.

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *