Implement Plugin Capabilities (e.g., CommandProvider)
mainComposer uses a Capability system to provide explicit extension points, reducing the need to manipulate internal state. To use capabilities, your plugin must implement Composer\Plugin\Capable and define them in the getCapabilities() method.
One common capability is Composer\Plugin\Capability\CommandProvider, which allows you to register new CLI commands. This requires a separate class that implements CommandProvider and returns an array of command instances (based on the Symfony Console component).
<?php
namespace My\Composer;
use Composer\Plugin\Capable;
use Composer\Plugin\PluginInterface;
use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability;
class Plugin implements PluginInterface, Capable
{
public function activate(\Composer\Composer $composer, \Composer\IO\IOInterface $io)
{
}
public function getCapabilities()
{
return [
'Composer\Plugin\Capability\CommandProvider' => 'My\Composer\CommandProvider',
];
}
}