Composer API
Class

Composer\Plugin\PluginManager

class PluginManager

Plugin manager

Methods

__construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, bool $disablePlugins = false)

Initializes plugin manager

loadInstalledPlugins()

Loads all plugins from currently installed plugin packages

array getPlugins()

Gets all currently active plugin instances

Composer|null getGlobalComposer()

Gets global composer or null when main composer is not fully loaded

registerPackage(PackageInterface $package, bool $failOnMissingClasses = false)

Register a plugin package, activate it etc.

addPlugin(PluginInterface $plugin)

Adds a plugin, activates it and registers it with the event dispatcher

null|Capability getPluginCapability(PluginInterface $plugin, string $capabilityClassName, array $ctorArgs = array())

Capability[] getPluginCapabilities(string $capabilityClassName, array $ctorArgs = array())

Details

at line 55
public __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, bool $disablePlugins = false)

Initializes plugin manager

Parameters

IOInterface $io
Composer $composer
Composer $globalComposer
bool $disablePlugins

at line 67
public loadInstalledPlugins()

Loads all plugins from currently installed plugin packages

at line 88
public array getPlugins()

Gets all currently active plugin instances

Return Value

array plugins

at line 98
public Composer|null getGlobalComposer()

Gets global composer or null when main composer is not fully loaded

Return Value

Composer|null

at line 114
public registerPackage(PackageInterface $package, bool $failOnMissingClasses = false)

Register a plugin package, activate it etc.

If it's of type composer-installer it is registered as an installer instead for BC

Parameters

PackageInterface $package
bool $failOnMissingClasses By default this silently skips plugins that can not be found, but if set to true it fails with an exception

Exceptions

UnexpectedValueException

at line 232
public addPlugin(PluginInterface $plugin)

Adds a plugin, activates it and registers it with the event dispatcher

Ideally plugin packages should be registered via registerPackage, but if you use Composer programmatically and want to register a plugin class directly this is a valid way to do it.

Parameters

PluginInterface $plugin plugin instance

at line 364
public null|Capability getPluginCapability(PluginInterface $plugin, string $capabilityClassName, array $ctorArgs = array())

Parameters

PluginInterface $plugin
string $capabilityClassName The fully qualified name of the API interface which the plugin may provide an implementation of.
array $ctorArgs Arguments passed to Capability's constructor. Keeping it an array will allow future values to be passed w\o changing the signature.

Return Value

null|Capability

at line 392
public Capability[] getPluginCapabilities(string $capabilityClassName, array $ctorArgs = array())

Parameters

string $capabilityClassName The fully qualified name of the API interface which the plugin may provide an implementation of.
array $ctorArgs Arguments passed to Capability's constructor. Keeping it an array will allow future values to be passed w\o changing the signature.

Return Value

Capability[]