This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.html
309 lines (262 loc) · 10.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<div class="container">
<div class="jumbotron">
<h1>zend-component-installer</h1>
<p>Composer plugin for injecting modules and configuration providers into application configuration.</p>
<pre><code class="language-bash">$ composer require --dev zendframework/zend-component-installer</code></pre>
</div>
</div>
<div class="container features">
<div class="row">
<div class="col-xs-12 col-sm-6">
<h2>Installable Packages</h2>
<p>
How do you define a package for which zend-component-installer will
install configuration?
</p>
<h3>Components</h3>
<p>
Components are Zend Framework modules that deliver low-level
functionality; examples include the various Zend Framework components
themselves. These require the following:
</p>
<ul>
<li>A <code>Module</code> class in the package namespace.</li>
<li>An <code>extra.zf.component</code> entry listing the package
namespace in your <code>composer.json</code>.</li>
</ul>
<pre><code class="lang-json" data-trim>
"extra": {
"zf": {
"component": "Some\\Component"
}
}
</code></pre>
<p>
You may also specify multiple components as an array:
</p>
<pre><code class="lang-json" data-trim>
"extra": {
"zf": {
"component": [
"Some\\Component",
"Other\\Component"
]
}
}
</code></pre>
<p>
Your application will need to have one or more of the following
configuration files, from which you will be prompted to choose which one
in which to inject the component:
</p>
<ul>
<li><code>config/application.config.php</code> (vanilla ZF2 application)</li>
<li><code>config/modules.config.php</code> (<a href="https://apigility.org">Apigility</a>
application)</li>
<li><code>config/development.config.php.dist</code> and
<code>config/development.config.php</code> (applications using
<a href="https://github.com/zendframework/zend-development-mode">zend-development-mode</a>)</li>
</ul>
<p>
Components are added at the <strong>top</strong> of the application's
list of modules.
</p>
<h3>Modules</h3>
<p>
Zend Framework modules typically deliver functionality around the
<a href="https://zendframework.github.io/zend-mvc/">zend-mvc</a>
workflow, including MVC event listeners, controllers, etc.
To enable the installer workflow, they require the following:
</p>
<ul>
<li>A <code>Module</code> class in the package namespace.</li>
<li>An <code>extra.zf.module</code> entry listing the package
namespace in your <code>composer.json</code>.</li>
</ul>
<pre><code class="lang-json" data-trim>
"extra": {
"zf": {
"module": "Some\\Component"
}
}
</code></pre>
<p>
You may also specify multiple modules as an array:
</p>
<pre><code class="lang-json" data-trim>
"extra": {
"zf": {
"module": [
"Some\\Component",
"Other\\Component"
]
}
}
</code></pre>
<p>
Your application will need to have one or more of the following
configuration files, from which you will be prompted to choose which one
in which to inject the module:
</p>
<ul>
<li><code>config/application.config.php</code> (vanilla ZF2 application)</li>
<li><code>config/modules.config.php</code> (<a href="https://apigility.org">Apigility</a>
application)</li>
<li><code>config/development.config.php.dist</code> and
<code>config/development.config.php</code> (applications using
<a href="https://github.com/zendframework/zend-development-mode">zend-development-mode</a>)</li>
</ul>
<p>
Modules are added at the <strong>bottom</strong> of the application's
list of modules.
</p>
<h3>Config Providers</h3>
<p>
Configuration providers work with
<a href="https://github.com/mtymek/expressive-config-manager">expressive-config-manager</a>,
which provides generic functionality for aggregating and merging
application configuration. Packages that provide configuration will
provide an invokable class that returns configuration for the package.
To enable the installer workflow, you will need:
</p>
<ul>
<li>A configuration provider class. This is a class with no constructor
arguments defining an <code>__invoke()</code> method returning a
configuration array.</li>
<li>An <code>extra.zf.config-provider</code> entry listing the
configuration provider class in your <code>composer.json</code>.</li>
</ul>
<pre><code class="lang-php" data-trim>
namespace Some\Component;
class ConfigProvider
{
public function __invoke()
{
return [ /* ... */ ];
}
}
</code></pre>
<pre><code class="lang-json" data-trim>
"extra": {
"zf": {
"config-provider": "Some\\Component\\ConfigProvider"
}
}
</code></pre>
<p>
You may also specify multiple configuration providers as an array:
</p>
<pre><code class="lang-json" data-trim>
"extra": {
"zf": {
"config-provider": [
"Some\\Component\\ConfigProvider",
"Some\\Component\\PluginConfigProvider",
]
}
}
</code></pre>
<p>
Your application will need to define a <code>config/config.php</code>
file, and that file will need to have a line that instantiates a
<code>Zend\Expressive\ConfigManager\ConfigManager</code> instance.
</p>
<p>
Configuration providers are added at the <strong>top</strong> of the
<code>ConfigManager</code> provider array.
</p>
</div>
<div class="col-xs-12 col-sm-6">
<div class="panel panel-success">
<div class="panel-heading">
<h2 class="panel-title">Global Installation</h2>
</div>
<div class="panel-body">
<p>
You can also install the plugin globally, in which case it will be
active for every project you manage on your machine.
</p>
<pre><code class="language-bash">$ composer global require zendframework/zend-component-installer</code></pre>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading">
<h2 class="panel-title">Why?</h2>
</div>
<div class="panel-body">
<p>
We're in the process of reducing the required components for zend-mvc
and the Zend Framework repository. In the current v2 series, zend-mvc
provides copious amounts of integrations with other components; as such,
we need to move the various factories, plugin managers, and event
listeners into the individual components themselves. Doing so, however,
has a side effect: they will no longer be wired automatically.
</p>
<p>
To provide service and event wiring, we will be adding <code>Module</code>
classes (and configuration providers) to all Zend Framework components.
This exposes a new problem, however: how do we ensure that those
components are then added to the application module list as you add them
to your application?
</p>
<p>
This package provides the answer to that problem. As soon as you add
this package to your application, whenever you add a component or module
that exposes itself as such, the plugin will prompt you, asking where
you want to inject it.
</p>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading">
<h2 class="panel-title">When are multiple items required?</h2>
</div>
<div class="panel-body">
<p>
As noted under each of the component, module, and config-provider
sections, you can optionally specify an <em>array</em> of items. When
would you do this?
</p>
<p>
The primary reason is for <a href="https://getcomposer.org/doc/04-schema.md#type">metapackages</a>.
Composer does not trigger either <code>post-package-install</code>
or <code>post-package-uninstall</code> events for packages defined
as metapackage requirements. As such, you would define the metadata
for such packages in the metapackage as well, to ensure that the
component installer can update the configuration accordingly.
</p>
<p>
The other use case is to allow specifying multiple configuration
providers from the same package. As an example, you might define
default configuration, plus configuration for plugins; specifying
these as separate configuration providers allows the consumer to
choose if they want both enabled in their application.
</p>
<div class="panel panel-warning">
<div class="panel-heading">
<h2 class="panel-title">Removing individual packages</h2>
</div>
<div class="panel-body">
<p>
When removing individual packages that were originally installed
via a metapackage, <em>the component installer will not
trigger</em>. As such, you will need to manually remove such
packages from your configuration.
</p>
<p>
Additionally, a later update may actually <em>re-install</em>
the package, as it's a requirement of the metapackage. As such,
it's typically safer to:
</p>
<ul>
<li>Remove the metapackage</li>
<li>Individually install the packages from the metapackage that
you wish to keep.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>