Chris@0
|
1 [![Latest Stable Version]](https://packagist.org/packages/wikimedia/composer-merge-plugin) [![License]](https://github.com/wikimedia/composer-merge-plugin/blob/master/LICENSE)
|
Chris@0
|
2 [![Build Status]](https://travis-ci.org/wikimedia/composer-merge-plugin)
|
Chris@0
|
3 [![Code Coverage]](https://scrutinizer-ci.com/g/wikimedia/composer-merge-plugin/?branch=master)
|
Chris@0
|
4
|
Chris@0
|
5 Composer Merge Plugin
|
Chris@0
|
6 =====================
|
Chris@0
|
7
|
Chris@0
|
8 Merge multiple composer.json files at [Composer] runtime.
|
Chris@0
|
9
|
Chris@0
|
10 Composer Merge Plugin is intended to allow easier dependency management for
|
Chris@0
|
11 applications which ship a composer.json file and expect some deployments to
|
Chris@0
|
12 install additional Composer managed libraries. It does this by allowing the
|
Chris@0
|
13 application's top level `composer.json` file to provide a list of optional
|
Chris@0
|
14 additional configuration files. When Composer is run it will parse these files
|
Chris@0
|
15 and merge their configuration settings into the base configuration. This
|
Chris@0
|
16 combined configuration will then be used when downloading additional libraries
|
Chris@0
|
17 and generating the autoloader.
|
Chris@0
|
18
|
Chris@0
|
19 Composer Merge Plugin was created to help with installation of [MediaWiki]
|
Chris@0
|
20 which has core library requirements as well as optional libraries and
|
Chris@0
|
21 extensions which may be managed via Composer.
|
Chris@0
|
22
|
Chris@0
|
23
|
Chris@0
|
24 Installation
|
Chris@0
|
25 ------------
|
Chris@0
|
26
|
Chris@0
|
27 Composer Merge Plugin requires [Composer 1.0.0](https://getcomposer.org/) or
|
Chris@0
|
28 newer.
|
Chris@0
|
29
|
Chris@0
|
30 ```
|
Chris@0
|
31 $ composer require wikimedia/composer-merge-plugin
|
Chris@0
|
32 ```
|
Chris@0
|
33
|
Chris@0
|
34
|
Chris@0
|
35 Usage
|
Chris@0
|
36 -----
|
Chris@0
|
37
|
Chris@0
|
38 ```json
|
Chris@0
|
39 {
|
Chris@0
|
40 "require": {
|
Chris@0
|
41 "wikimedia/composer-merge-plugin": "dev-master"
|
Chris@0
|
42 },
|
Chris@0
|
43 "extra": {
|
Chris@0
|
44 "merge-plugin": {
|
Chris@0
|
45 "include": [
|
Chris@0
|
46 "composer.local.json",
|
Chris@0
|
47 "extensions/*/composer.json"
|
Chris@0
|
48 ],
|
Chris@0
|
49 "require": [
|
Chris@0
|
50 "submodule/composer.json"
|
Chris@0
|
51 ],
|
Chris@0
|
52 "recurse": true,
|
Chris@0
|
53 "replace": false,
|
Chris@0
|
54 "ignore-duplicates": false,
|
Chris@0
|
55 "merge-dev": true,
|
Chris@0
|
56 "merge-extra": false,
|
Chris@0
|
57 "merge-extra-deep": false,
|
Chris@0
|
58 "merge-scripts": false
|
Chris@0
|
59 }
|
Chris@0
|
60 }
|
Chris@0
|
61 }
|
Chris@0
|
62 ```
|
Chris@0
|
63
|
Chris@0
|
64
|
Chris@0
|
65 Plugin configuration
|
Chris@0
|
66 --------------------
|
Chris@0
|
67
|
Chris@0
|
68 The plugin reads its configuration from the `merge-plugin` section of your
|
Chris@0
|
69 composer.json's `extra` section. An `include` setting is required to tell
|
Chris@0
|
70 Composer Merge Plugin which file(s) to merge.
|
Chris@0
|
71
|
Chris@0
|
72
|
Chris@0
|
73 ### include
|
Chris@0
|
74
|
Chris@0
|
75 The `include` setting can specify either a single value or an array of values.
|
Chris@0
|
76 Each value is treated as a PHP `glob()` pattern identifying additional
|
Chris@0
|
77 composer.json style configuration files to merge into the root package
|
Chris@0
|
78 configuration for the current Composer execution.
|
Chris@0
|
79
|
Chris@0
|
80 The following sections of the found configuration files will be merged into
|
Chris@0
|
81 the Composer root package configuration as though they were directly included
|
Chris@0
|
82 in the top-level composer.json file:
|
Chris@0
|
83
|
Chris@0
|
84 * [autoload](https://getcomposer.org/doc/04-schema.md#autoload)
|
Chris@0
|
85 * [autoload-dev](https://getcomposer.org/doc/04-schema.md#autoload-dev)
|
Chris@0
|
86 (optional, see [merge-dev](#merge-dev) below)
|
Chris@0
|
87 * [conflict](https://getcomposer.org/doc/04-schema.md#conflict)
|
Chris@0
|
88 * [provide](https://getcomposer.org/doc/04-schema.md#provide)
|
Chris@0
|
89 * [replace](https://getcomposer.org/doc/04-schema.md#replace)
|
Chris@0
|
90 * [repositories](https://getcomposer.org/doc/04-schema.md#repositories)
|
Chris@0
|
91 * [require](https://getcomposer.org/doc/04-schema.md#require)
|
Chris@0
|
92 * [require-dev](https://getcomposer.org/doc/04-schema.md#require-dev)
|
Chris@0
|
93 (optional, see [merge-dev](#merge-dev) below)
|
Chris@0
|
94 * [suggest](https://getcomposer.org/doc/04-schema.md#suggest)
|
Chris@0
|
95 * [extra](https://getcomposer.org/doc/04-schema.md#extra)
|
Chris@0
|
96 (optional, see [merge-extra](#merge-extra) below)
|
Chris@0
|
97 * [scripts](https://getcomposer.org/doc/04-schema.md#scripts)
|
Chris@0
|
98 (optional, see [merge-scripts](#merge-scripts) below)
|
Chris@0
|
99
|
Chris@0
|
100
|
Chris@0
|
101 ### require
|
Chris@0
|
102
|
Chris@0
|
103 The `require` setting is identical to [`include`](#include) except when
|
Chris@0
|
104 a pattern fails to match at least one file then it will cause an error.
|
Chris@0
|
105
|
Chris@0
|
106 ### recurse
|
Chris@0
|
107
|
Chris@0
|
108 By default the merge plugin is recursive; if an included file has
|
Chris@0
|
109 a `merge-plugin` section it will also be processed. This functionality can be
|
Chris@0
|
110 disabled by adding a `"recurse": false` setting.
|
Chris@0
|
111
|
Chris@0
|
112
|
Chris@0
|
113 ### replace
|
Chris@0
|
114
|
Chris@0
|
115 By default, Composer's conflict resolution engine is used to determine which
|
Chris@0
|
116 version of a package should be installed when multiple files specify the same
|
Chris@0
|
117 package. A `"replace": true` setting can be provided to change to a "last
|
Chris@0
|
118 version specified wins" conflict resolution strategy. In this mode, duplicate
|
Chris@0
|
119 package declarations found in merged files will overwrite the declarations
|
Chris@0
|
120 made by earlier files. Files are loaded in the order specified by the
|
Chris@0
|
121 `include` setting with globbed files being processed in alphabetical order.
|
Chris@0
|
122
|
Chris@0
|
123 ### ignore-duplicates
|
Chris@0
|
124
|
Chris@0
|
125 By default, Composer's conflict resolution engine is used to determine which
|
Chris@0
|
126 version of a package should be installed when multiple files specify the same
|
Chris@0
|
127 package. An `"ignore-duplicates": true` setting can be provided to change to
|
Chris@0
|
128 a "first version specified wins" conflict resolution strategy. In this mode,
|
Chris@0
|
129 duplicate package declarations found in merged files will be ignored in favor
|
Chris@0
|
130 of the declarations made by earlier files. Files are loaded in the order
|
Chris@0
|
131 specified by the `include` setting with globbed files being processed in
|
Chris@0
|
132 alphabetical order.
|
Chris@0
|
133
|
Chris@0
|
134 Note: `"replace": true` and `"ignore-duplicates": true` modes are mutually
|
Chris@0
|
135 exclusive. If both are set, `"ignore-duplicates": true` will be used.
|
Chris@0
|
136
|
Chris@0
|
137 ### merge-dev
|
Chris@0
|
138
|
Chris@0
|
139 By default, `autoload-dev` and `require-dev` sections of included files are
|
Chris@0
|
140 merged. A `"merge-dev": false` setting will disable this behavior.
|
Chris@0
|
141
|
Chris@0
|
142
|
Chris@0
|
143 ### merge-extra
|
Chris@0
|
144
|
Chris@0
|
145 A `"merge-extra": true` setting enables the merging the contents of the
|
Chris@0
|
146 `extra` section of included files as well. The normal merge mode for the extra
|
Chris@0
|
147 section is to accept the first version of any key found (e.g. a key in the
|
Chris@0
|
148 master config wins over the version found in any imported config). If
|
Chris@0
|
149 `replace` mode is active ([see above](#replace)) then this behavior changes
|
Chris@0
|
150 and the last key found will win (e.g. the key in the master config is replaced
|
Chris@0
|
151 by the key in the imported config). If `"merge-extra-deep": true` is specified
|
Chris@0
|
152 then, the sections are merged similar to array_merge_recursive() - however
|
Chris@0
|
153 duplicate string array keys are replaced instead of merged, while numeric
|
Chris@0
|
154 array keys are merged as usual. The usefulness of merging the extra section
|
Chris@0
|
155 will vary depending on the Composer plugins being used and the order in which
|
Chris@0
|
156 they are processed by Composer.
|
Chris@0
|
157
|
Chris@0
|
158 Note that `merge-plugin` sections are excluded from the merge process, but are
|
Chris@0
|
159 always processed by the plugin unless [recursion](#recurse) is disabled.
|
Chris@0
|
160
|
Chris@0
|
161 ### merge-scripts
|
Chris@0
|
162
|
Chris@0
|
163 A `"merge-scripts": true` setting enables merging the contents of the
|
Chris@0
|
164 `scripts` section of included files as well. The normal merge mode for the
|
Chris@0
|
165 scripts section is to accept the first version of any key found (e.g. a key in
|
Chris@0
|
166 the master config wins over the version found in any imported config). If
|
Chris@0
|
167 `replace` mode is active ([see above](#replace)) then this behavior changes
|
Chris@0
|
168 and the last key found will win (e.g. the key in the master config is replaced
|
Chris@0
|
169 by the key in the imported config).
|
Chris@0
|
170
|
Chris@0
|
171 Note: [custom commands][] added by merged configuration will work when invoked
|
Chris@0
|
172 as `composer run-script my-cool-command` but will not be available using the
|
Chris@0
|
173 normal `composer my-cool-command` shortcut.
|
Chris@0
|
174
|
Chris@0
|
175
|
Chris@0
|
176 Running tests
|
Chris@0
|
177 -------------
|
Chris@0
|
178
|
Chris@0
|
179 ```
|
Chris@0
|
180 $ composer install
|
Chris@0
|
181 $ composer test
|
Chris@0
|
182 ```
|
Chris@0
|
183
|
Chris@0
|
184
|
Chris@0
|
185 Contributing
|
Chris@0
|
186 ------------
|
Chris@0
|
187
|
Chris@0
|
188 Bug, feature requests and other issues should be reported to the [GitHub
|
Chris@0
|
189 project]. We accept code and documentation contributions via Pull Requests on
|
Chris@0
|
190 GitHub as well.
|
Chris@0
|
191
|
Chris@0
|
192 - [PSR-2 Coding Standard][] is used by the project. The included test
|
Chris@0
|
193 configuration uses [PHP Code Sniffer][] to validate the conventions.
|
Chris@0
|
194 - Tests are encouraged. Our test coverage isn't perfect but we'd like it to
|
Chris@0
|
195 get better rather than worse, so please try to include tests with your
|
Chris@0
|
196 changes.
|
Chris@0
|
197 - Keep the documentation up to date. Make sure `README.md` and other
|
Chris@0
|
198 relevant documentation is kept up to date with your changes.
|
Chris@0
|
199 - One pull request per feature. Try to keep your changes focused on solving
|
Chris@0
|
200 a single problem. This will make it easier for us to review the change and
|
Chris@0
|
201 easier for you to make sure you have updated the necessary tests and
|
Chris@0
|
202 documentation.
|
Chris@0
|
203
|
Chris@0
|
204
|
Chris@0
|
205 License
|
Chris@0
|
206 -------
|
Chris@0
|
207
|
Chris@0
|
208 Composer Merge plugin is licensed under the MIT license. See the
|
Chris@0
|
209 [`LICENSE`](LICENSE) file for more details.
|
Chris@0
|
210
|
Chris@0
|
211
|
Chris@0
|
212 ---
|
Chris@0
|
213 [Composer]: https://getcomposer.org/
|
Chris@0
|
214 [MediaWiki]: https://www.mediawiki.org/wiki/MediaWiki
|
Chris@0
|
215 [GitHub project]: https://github.com/wikimedia/composer-merge-plugin
|
Chris@0
|
216 [PSR-2 Coding Standard]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
|
Chris@0
|
217 [PHP Code Sniffer]: http://pear.php.net/package/PHP_CodeSniffer
|
Chris@0
|
218 [Latest Stable Version]: https://img.shields.io/packagist/v/wikimedia/composer-merge-plugin.svg?style=flat
|
Chris@0
|
219 [License]: https://img.shields.io/packagist/l/wikimedia/composer-merge-plugin.svg?style=flat
|
Chris@0
|
220 [Build Status]: https://img.shields.io/travis/wikimedia/composer-merge-plugin.svg?style=flat
|
Chris@0
|
221 [Code Coverage]: https://img.shields.io/scrutinizer/coverage/g/wikimedia/composer-merge-plugin/master.svg?style=flat
|
Chris@0
|
222 [custom commands]: https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands
|