Usage of Composer

Composer - a dependency manager, or rather, a package manager for php.

Official website:

Allows you to keep track of components used in a php application, install them, update them, etc.


curl -sS | php
Or simply download the file from the website if your religion prohibits the use of curl.

The composer.json file is used to describe the configuration.

The require key specifies the list of packages used and their versions, for example:

    "require": {
        "twig/twig": "v1.14.1"
In addition, there is a require-dev key, which allows you to specify a list of packages used only in dev mode:

    "require-dev": {
        "phpunit/phpunit": "3.7.*@dev"
Also, a nice feature is the simplicity of installing the autoloader:

    "autoload": {
        "psr-0": {
            "Namespace\": "src/"
After describing the dependencies in composer.json, you can use the following commands:
composer.phar install
to install packages,
composer.phar update
to update them. You can also write:
composer.phar require package_name
and search for the necessary component from the database using prompts. In this case, there is no need to specify anything in composer.json, it will be done during installation.

Package database for installation:

There is also the ability to install components from GitHub.

That's it for the brief introduction to composer =)