diff --git a/doc/articles/plugins.md b/doc/articles/plugins.md index b4997d22d..9af6103c7 100644 --- a/doc/articles/plugins.md +++ b/doc/articles/plugins.md @@ -183,6 +183,76 @@ class AwsPlugin implements PluginInterface, EventSubscriberInterface } ``` + +## Plugin capabilities + +Composer defines a standard set of capabilities which may be implemented by plugins +through the [`Composer\Plugin\Capable`][8] interface. + +### Command provider + +The [`Composer\Plugin\Capability\CommandProvider`][9] capability allows to register +additional commands for Composer : + +```php +setName('custom-plugin-command'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('Executing'); + } +} +``` + +Once the plugin exposes this capability, `custom-plugin-command` is +available alongside Composer commands : + +```php + 'My\Composer\CommandProvider', + ); + } +} +``` + ## Using Plugins Plugin packages are automatically loaded as soon as they are installed and will @@ -202,3 +272,5 @@ local project plugins are loaded. [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 [7]: ../01-basic-usage.md#package-versions +[8]: https://github.com/composer/composer/blob/master/src/Composer/Plugin/Capable.php +[9]: https://github.com/composer/composer/blob/master/src/Composer/Plugin/Capability/CommandProvider.php