{% extends "PackagistWebBundle::layout.html.twig" %}

{% block content %}
    <div class="box clearfix">
        <h1>What is Composer?</h1>
        <p>Composer helps you manage your project or libraries' dependencies. You can find the Composer source on <a href="https://github.com/composer/composer">GitHub</a>.</p>

        <h1>Declaring dependencies</h1>
        <p>To define your project's dependencies, you can use a composer.json file, just like in a library or plugin, but you don't have to specify most of the fields.</p>
        <p>A typical composer.json file for a project looks like this:</p>
<pre>
{
    "name": "my-project",
    "version": "1.0.0",
    "require": {
        "monolog/monolog": "1.0.0"
    }
}
</pre>
        <p>In this example, the project only requires the Monolog library as a dependency.</p>

        <h2>Adding more package repositories</h2>
        <p>You can add different repositories than Packagist, if needed, by specifying them by hand. They all sit in the "repositories" key, and each are made of a name (which is only for your use, for self-documenting purposes), a type, and then a configuration.</p>

        <h2>Adding another Composer repository</h2>
        <p>Packagist is a Composer repository, it contains a list of all packages under <em>/packages.json</em>. You can set one up for your own use, you will find the sources on <a href="https://github.com/composer/packagist">GitHub</a>. You can set it up in Composer like this:
<pre>
{
    "repositories": {
        "my-repo": {
            "composer": {
                "url": "http://example.org"
            }
        }
    }
}
</pre>

        <h2>Removing the default Packagist repository</h2>
        <p>If you do not wish to work with Packagist.org packages, you can disable it like that:</p>
<pre>
{
    "repositories": {
        "packagist": false
    }
}
</pre>
        <p>Of course if you do that you should define an alternative repository or Composer will be pretty useless.</p>

        <h2>Adding a git repository containing a composer package</h2>
        <p>VCS (only Git so far) repositories can be used as repositories if they contain a composer.json, even if the packages are not available on Packagist. They could also be private repositories that you don't want to make accessible to everyone. Here's how to do it:</p>
<pre>
{
    "name": "my-project",
    "version": "1.0.0",
    "repositories": {
        "MyRepo": {
            "vcs": {
                "url": "git://example.org/MyRepo.git"
            }
        }
    },
    "require": {
        "monolog/monolog": "1.0.0",
        "myvendor/mypackage": ">=1.0.0"
    }
}
</pre>

        <h2>Adding code that does not support composer</h2>
        <p>If you wish to use a repository that does not contain composer.json as a dependency, you can define its package information inline with the package repository, for example:</p>
<pre>
{
    "repositories": {
        "some vendor repo": {
            "package": {
                "name": "vendor/package",
                "version": "1.0.0",
                "dist": {
                    "url": "http://example.org/package.zip",
                    "type": "zip"
                },
                "source": {
                    "url": "git://example.org/package.git",
                    "type": "git",
                    "reference": "tag name, branch name or commit hash"
                }
            }
        }
    },
    "require": {
        "vendor/package": "1.0.0"
    }
}
</pre>
        <p>You only have to specify one of the two dist/source keys, but specifying both makes it more flexble.</p>

        <h2>Adding PEAR packages</h2>
        <p>If a library does not have a composer package but offers PEAR packages, you can also add it to composer. You just need to specify it's PEAR channel and all the channels of it's dependencies:</p>
<pre>
{
    "repositories": {
        "example org": {
            "pear": {
                "url": "http://pear.example.org"
            }
        },
        "example com": {
            "pear": {
                "url": "http://pear.example.com"
            }
        }
    },
    "require": {
        "SomePackage": "1.0.0"
    }
}
</pre>
        <p>Note that SomePackage does not take the channel name in front of it. Also be careful, this can take quite a while with large channels containing many versions.</p>

        <h1>Community</h1>
        <p>If you have questions about composer or want to help out, come and join us in the <em><a href="irc://irc.freenode.net/#composer-dev">#composer-dev</a></em> channel on irc.freenode.net.</p>
        <p>Also join the <em><a href="http://groups.google.com/group/composer-dev">composer-dev mailing list</a></em>.</p>
    </div>
{% endblock %}