|
@@ -6,7 +6,7 @@
|
|
|
|
|
|
<h1>Declaring dependencies</h1>
|
|
<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>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>A typical composer.json file for a project looks like this:</p>
|
|
<pre>
|
|
<pre>
|
|
{
|
|
{
|
|
"name": "my-project",
|
|
"name": "my-project",
|
|
@@ -16,10 +16,38 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</pre>
|
|
</pre>
|
|
- In this example, the project only requires the Monolog library as a dependency.</p>
|
|
|
|
|
|
+ <p>In this example, the project only requires the Monolog library as a dependency.</p>
|
|
|
|
|
|
<h2>Adding more package repositories</h2>
|
|
<h2>Adding more package repositories</h2>
|
|
- <p>You can add different repositories than Packagist, if needed, by specifying them by hand. For example git 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>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>Git 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>
|
|
<pre>
|
|
{
|
|
{
|
|
"name": "my-project",
|
|
"name": "my-project",
|
|
@@ -36,16 +64,16 @@
|
|
"myvendor/mypackage": ">=1.0.0"
|
|
"myvendor/mypackage": ">=1.0.0"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-</pre></p>
|
|
|
|
|
|
+</pre>
|
|
|
|
|
|
<h2>Adding code that does not support composer</h2>
|
|
<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>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>
|
|
<pre>
|
|
{
|
|
{
|
|
"repositories": {
|
|
"repositories": {
|
|
- "annoying-vendor": {
|
|
|
|
|
|
+ "some vendor repo": {
|
|
"package": {
|
|
"package": {
|
|
- "name": "annoying/package",
|
|
|
|
|
|
+ "name": "vendor/package",
|
|
"version": "1.0.0",
|
|
"version": "1.0.0",
|
|
"dist": {
|
|
"dist": {
|
|
"url": "http://example.org/package.zip",
|
|
"url": "http://example.org/package.zip",
|
|
@@ -60,14 +88,14 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
"require": {
|
|
"require": {
|
|
- "annoying/package": "1.0.0"
|
|
|
|
|
|
+ "vendor/package": "1.0.0"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</pre>
|
|
</pre>
|
|
- You only have to specify one of the two dist/source keys, but specifying both makes it more flexble.</p>
|
|
|
|
|
|
+ <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>
|
|
<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>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>
|
|
<pre>
|
|
{
|
|
{
|
|
"repositories": {
|
|
"repositories": {
|
|
@@ -87,18 +115,7 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</pre>
|
|
</pre>
|
|
- 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>
|
|
|
|
-
|
|
|
|
- <h2>Removing the default Packagist repository</h2>
|
|
|
|
- <p>If you do not wish to work with Packagist packages, you can disable it like that:
|
|
|
|
-<pre>
|
|
|
|
-{
|
|
|
|
- "repositories": {
|
|
|
|
- "packagist": false
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-</pre>
|
|
|
|
- Of course if you do that you should define an alternative repository or Composer will be pretty useless.</p>
|
|
|
|
|
|
+ <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>
|
|
<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>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>
|