1
0
Fork 0

Update docs

pull/4089/head
nevvermind 2015-06-02 19:09:57 +01:00
parent 3032f0a538
commit 00da5945ec
1 changed files with 23 additions and 9 deletions

View File

@ -16,7 +16,7 @@ specific logic.
## Creating a Plugin ## Creating a Plugin
A plugin is a regular composer package which ships its code as part of the A plugin is a regular Composer package which ships its code as part of the
package and may also depend on further packages. package and may also depend on further packages.
### Plugin Package ### Plugin Package
@ -24,23 +24,36 @@ package and may also depend on further packages.
The package file is the same as any other package file but with the following The package file is the same as any other package file but with the following
requirements: requirements:
1. the [type][1] attribute must be `composer-plugin`. 1. The [type][1] attribute must be `composer-plugin`.
2. the [extra][2] attribute must contain an element `class` defining the 2. The [extra][2] attribute must contain an element `class` defining the
class name of the plugin (including namespace). If a package contains class name of the plugin (including namespace). If a package contains
multiple plugins this can be array of class names. multiple plugins, this can be array of class names.
3. You must require the special package called `composer-plugin-api`
to define which Plugin API versions your plugin is compatible with.
Additionally you must require the special package called `composer-plugin-api` The required version of the `composer-plugin-api` follows the same [rules][7]
to define which composer API versions your plugin is compatible with. The as a normal package's, except for the `1.0`, `1.0.0` and `1.0.0.0` _exact_
current composer plugin API version is 1.0.0. values. In only these three cases, Composer will assume your plugin
actually meant `^1.0` instead. This was introduced to maintain BC with
the old style of declaring the Plugin API version.
For example In other words, `"require": { "composer-plugin-api": "1.0.0" }` means
`"require": { "composer-plugin-api": "^1.0" }`.
The current composer plugin API version is 1.0.0.
An example of a valid plugin `composer.json` file (with the autoloading
part omitted):
```json ```json
{ {
"name": "my/plugin-package", "name": "my/plugin-package",
"type": "composer-plugin", "type": "composer-plugin",
"require": { "require": {
"composer-plugin-api": "1.0.0" "composer-plugin-api": "~1.0"
},
"extra": {
"class": "My\\Plugin"
} }
} }
``` ```
@ -149,3 +162,4 @@ local project plugins are loaded.
[4]: https://github.com/composer/composer/blob/master/src/Composer/Composer.php [4]: https://github.com/composer/composer/blob/master/src/Composer/Composer.php
[5]: https://github.com/composer/composer/blob/master/src/Composer/IO/IOInterface.php [5]: https://github.com/composer/composer/blob/master/src/Composer/IO/IOInterface.php
[6]: https://github.com/composer/composer/blob/master/src/Composer/EventDispatcher/EventSubscriberInterface.php [6]: https://github.com/composer/composer/blob/master/src/Composer/EventDispatcher/EventSubscriberInterface.php
[7]: ../01-basic-usage.md#package-versions