Documentation

MergePlugin
in package
implements PluginInterface, EventSubscriberInterface

Composer plugin that allows merging multiple composer.json files.

When installed, this plugin will look for a "merge-plugin" key in the composer configuration's "extra" section. The value for this key is a set of options configuring the plugin.

An "include" setting is required. The value of this setting can be either a single value or an array of values. Each value is treated as a glob() pattern identifying additional composer.json style configuration files to merge into the configuration for the current compser execution.

The "autoload", "autoload-dev", "conflict", "provide", "replace", "repositories", "require", "require-dev", and "suggest" sections of the found configuration files will be merged into the root package configuration as though they were directly included in the top-level composer.json file.

If included files specify conflicting package versions for "require" or "require-dev", the normal Composer dependency solver process will be used to attempt to resolve the conflict. Specifying the 'replace' key as true will change this default behaviour so that the last-defined version of a package will win, allowing for force-overrides of package defines.

By default the "extra" section is not merged. This can be enabled by setitng the 'merge-extra' key to true. In normal mode, when the same key is found in both the original and the imported extra section, the version in the original config is used and the imported version is skipped. If 'replace' mode is active, this behaviour changes so the imported version of the key is used, replacing the version in the original config.

Tags
code

{ "require": { "wikimedia/composer-merge-plugin": "dev-master" }, "extra": { "merge-plugin": { "include": [ "composer.local.json" ] } } }

endcode
author

Bryan Davis bd808@bd808.com

Interfaces, Classes and Traits

PluginInterface
Plugin interface
EventSubscriberInterface
An EventSubscriber knows which events it is interested in.

Table of Contents

CALLBACK_PRIORITY  = 50000
Priority that plugin uses to register callbacks.
COMPAT_PLUGINEVENTS_INIT  = 'init'
Name of the composer 1.1 init event.
PACKAGE_NAME  = 'wikimedia/composer-merge-plugin'
Offical package name
$composer  : Composer
$loaded  : array<string|int, string>
Files that have already been fully processed
$loadedNoDev  : array<string|int, string>
Files that have already been partially processed
$logger  : Logger
$state  : PluginState
activate()  : mixed
Apply plugin modifications to Composer
getSubscribedEvents()  : array<string|int, mixed>
Returns an array of event names this subscriber wants to listen to.
onDependencySolve()  : mixed
Handle an event callback for pre-dependency solving phase of an install or update by adding any duplicate package dependencies found during initial merge processing to the request that will be processed by the dependency solver.
onInit()  : mixed
Handle an event callback for initialization.
onInstallUpdateOrDump()  : mixed
Handle an event callback for an install, update or dump command by checking for "merge-plugin" in the "extra" data and merging package contents if found.
onPostInstallOrUpdate()  : mixed
Handle an event callback following an install or update command. If our plugin was installed during the run then trigger an update command to process any merge-patterns in the current config.
onPostPackageInstall()  : mixed
Handle an event callback following installation of a new package by checking to see if the package that was installed was our plugin.
mergeFile()  : mixed
Read a JSON file and merge its contents
mergeFiles()  : mixed
Find configuration files matching the configured glob patterns and merge their contents with the master package.

Constants

CALLBACK_PRIORITY

Priority that plugin uses to register callbacks.

public mixed CALLBACK_PRIORITY = 50000

COMPAT_PLUGINEVENTS_INIT

Name of the composer 1.1 init event.

public mixed COMPAT_PLUGINEVENTS_INIT = 'init'

PACKAGE_NAME

Offical package name

public mixed PACKAGE_NAME = 'wikimedia/composer-merge-plugin'

Properties

$loaded

Files that have already been fully processed

protected array<string|int, string> $loaded = array()

$loadedNoDev

Files that have already been partially processed

protected array<string|int, string> $loadedNoDev = array()

Methods

getSubscribedEvents()

Returns an array of event names this subscriber wants to listen to.

public static getSubscribedEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

The event names to listen to

onDependencySolve()

Handle an event callback for pre-dependency solving phase of an install or update by adding any duplicate package dependencies found during initial merge processing to the request that will be processed by the dependency solver.

public onDependencySolve(InstallerEvent $event) : mixed
Parameters
$event : InstallerEvent
Return values
mixed

onInit()

Handle an event callback for initialization.

public onInit(Event $event) : mixed
Parameters
$event : Event
Return values
mixed

onInstallUpdateOrDump()

Handle an event callback for an install, update or dump command by checking for "merge-plugin" in the "extra" data and merging package contents if found.

public onInstallUpdateOrDump(Event $event) : mixed
Parameters
$event : Event
Return values
mixed

onPostInstallOrUpdate()

Handle an event callback following an install or update command. If our plugin was installed during the run then trigger an update command to process any merge-patterns in the current config.

public onPostInstallOrUpdate(Event $event) : mixed
Parameters
$event : Event
Return values
mixed

onPostPackageInstall()

Handle an event callback following installation of a new package by checking to see if the package that was installed was our plugin.

public onPostPackageInstall(PackageEvent $event) : mixed
Parameters
$event : PackageEvent
Return values
mixed

mergeFiles()

Find configuration files matching the configured glob patterns and merge their contents with the master package.

protected mergeFiles(array<string|int, mixed> $patterns[, bool $required = false ]) : mixed
Parameters
$patterns : array<string|int, mixed>

List of files/glob patterns

$required : bool = false

Are the patterns required to match files?

Tags
throws
MissingFileException

when required and a pattern returns no results

Return values
mixed

Search results