You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you ever wondered if Android market sends you information at the moment of app install? Wouldn"t be nice to create custom links to your android application, including bits of information about the referrer, and send it directly to the app for <ahref="http://www.cillap.com/">online casino</a> processing at install? This could be a simple and accurate solution for mobile app install tracking but I"m sure you can find this useful in many ways.
28
+
29
+
With Android, you actually get this information as a broadcasted intent by android market at install time - even before opening your app...
Did you come to a point where using multiple broadcast receivers to listen for the same intent, separatly, in the same android app, leads to unexpected results? If that"s the case, one broadcast receiver might consume the broadcasted intent, <ahref="http://www.cillap.com/">online casino</a> leaving the others with nothing to receive. This can be the case where you use 3rd party libraries with broadcast receivers defined.
28
+
29
+
The following is a solution for this kind of problem, a code snippet inspired by the way Admob for android seems to solve this, as shown in their <atitle="Admob Download Tracking"href="http://developer.admob.com/wiki/Android_App_Download_Tracking"target="_blank"rel="noopener noreferrer">documentation</a>, using meta-data in manifest file....
<pclass="mb-3">In PHP, the <code>ConfigProvider</code> is a class that is part of an application's bootstrap process. <strong>It's a class or callable that returns configuration data telling the platform which middleware should run, in what order, and sometimes under what conditions.</strong></p>
29
+
<!-- /wp:paragraph -->
30
+
31
+
<!-- wp:paragraph -->
32
+
<pclass="mb-3">If you're talking specifically about the ConfigProvider in the Laminas/Mezzio ecosystem, it's literally an array of configuration, settings, or anything else your application needs.</p>
33
+
<!-- /wp:paragraph -->
34
+
35
+
<!-- wp:heading -->
36
+
<h2class="wp-block-heading"><ahref="#where-is-the-configprovider-used"></a>Where Is the ConfigProvider Used?</h2>
37
+
<!-- /wp:heading -->
38
+
39
+
<!-- wp:paragraph -->
40
+
<pclass="mb-3">Mezzio (formerly Zend Expressive), Laminas, Slim, the Dotkernel Headless Platform, or other middleware-based frameworks often have a <code>ConfigProvider</code> class. In Laminas/Mezzio specifically, each module or package may contain a <code>ConfigProvider</code> that returns:</p>
<li><code>dependencies</code> is used by the dependency injector (like <ahref="https://docs.mezzio.dev/mezzio/v3/features/container/laminas-servicemanager/"target="_blank"rel="noreferrer noopener">laminas-servicemanager</a>) to construct every requested service.<!-- wp:list -->
104
+
<ulclass="wp-block-list"><!-- wp:list-item -->
105
+
<li><code>factories</code> will have the factory build the service.</li>
106
+
<!-- /wp:list-item -->
107
+
108
+
<!-- wp:list-item -->
109
+
<li><code>invokables</code> will use <code>new</code> directly.</li>
110
+
<!-- /wp:list-item -->
111
+
112
+
<!-- wp:list-item -->
113
+
<li>You can also use <code>aliases</code> to redirect to another service name and <code>delegators</code> to wrap the original service.</li>
114
+
<!-- /wp:list-item --></ul>
115
+
<!-- /wp:list --></li>
116
+
<!-- /wp:list-item -->
117
+
118
+
<!-- wp:list-item -->
119
+
<li><code>templates</code> defines the paths for the template files.</li>
120
+
<!-- /wp:list-item --></ul>
121
+
<!-- /wp:list -->
122
+
123
+
<!-- wp:heading -->
124
+
<h2class="wp-block-heading"><ahref="#how-the-configprovider-works"></a>How the ConfigProvider works</h2>
125
+
<!-- /wp:heading -->
126
+
127
+
<!-- wp:paragraph -->
128
+
<pclass="mb-3">The ConfigProvider is automatically picked up by the framework during application bootstrap. Let's look at it step by step:</p>
129
+
<!-- /wp:paragraph -->
130
+
131
+
<!-- wp:list -->
132
+
<ulclass="wp-block-list"><!-- wp:list-item -->
133
+
<li><strong>Merge the global configuration</strong> - All ConfigProviders are merged into one array.</li>
134
+
<!-- /wp:list-item -->
135
+
136
+
<!-- wp:list-item -->
137
+
<li><strong>Read the configuration array</strong> - The call is similar to the below and expects an array of entries:</li>
<li><strong>Resolve item</strong> - <code>$app->pipe()</code> is called to resolve one of the below instances:<!-- wp:list -->
148
+
<ulclass="wp-block-list"><!-- wp:list-item -->
149
+
<li>Resolve the service name from the container</li>
150
+
<!-- /wp:list-item -->
151
+
152
+
<!-- wp:list-item -->
153
+
<li>Wrap the middleware, if an array is provided</li>
154
+
<!-- /wp:list-item -->
155
+
156
+
<!-- wp:list-item -->
157
+
<li>Call the closure or invokable object.</li>
158
+
<!-- /wp:list-item --></ul>
159
+
<!-- /wp:list --></li>
160
+
<!-- /wp:list-item -->
161
+
162
+
<!-- wp:list-item -->
163
+
<li><strong>Handle errors</strong> - This middleware is the last one in the pipeline to make sure it handles any exceptions.</li>
164
+
<!-- /wp:list-item -->
165
+
166
+
<!-- wp:list-item -->
167
+
<li><strong>Execute at runtime</strong> - <ahref="https://docs.laminas.dev/laminas-stratigility/"target="_blank"rel="noreferrer noopener">Laminas Stratigility</a> iterates over the pipeline in the order it was registered.<!-- wp:list -->
168
+
<ulclass="wp-block-list"><!-- wp:list-item -->
169
+
<li>Each middleware can <strong>handle</strong> the request and return a response, or <strong>delegate</strong> execution to the next middleware in the pipeline, until a <code>ResponseInterface</code> is returned to the client.</li>
170
+
<!-- /wp:list-item --></ul>
171
+
<!-- /wp:list --></li>
172
+
<!-- /wp:list-item --></ul>
173
+
<!-- /wp:list -->
174
+
175
+
<!-- wp:paragraph -->
176
+
<pclass="mb-3">Below you can see how Mezzio and Dotkernel merge and use ConfigProviders to build the middleware pipeline and dependencies.</p>
<li>Centralized setup – Instead of hardcoding bootstrap code, you declare it in a config provider so it's easy to read, change, or extend.</li>
190
+
<!-- /wp:list-item -->
191
+
192
+
<!-- wp:list-item -->
193
+
<li>Modular – Each package can ship with its own config without interfering with others.</li>
194
+
<!-- /wp:list-item -->
195
+
196
+
<!-- wp:list-item -->
197
+
<li>Container-friendly – It works well with frameworks using DI containers like Laminas ServiceManager, PHP-DI, or Pimple.</li>
198
+
<!-- /wp:list-item -->
199
+
200
+
<!-- wp:list-item -->
201
+
<li>Standardized service definitions - It has consistent rules for object creation that are separate from business logic.</li>
202
+
<!-- /wp:list-item -->
203
+
204
+
<!-- wp:list-item -->
205
+
<li>Auto-Discovery - In Laminas/Mezzio, the <ahref="https://docs.laminas.dev/laminas-config-aggregator/"target="_blank"rel="noreferrer noopener">ConfigAggregator</a> automatically loads and merges all ConfigProviders.</li>
<pclass="mb-3">Dotkernel is an exception to this rule: new ConfigProviders have to be added manually in <code>config/config.php</code>, because all the initial ConfigProviders required to install the applications are already injected.</p>
212
+
<!-- /wp:paragraph --></blockquote>
213
+
<!-- /wp:quote -->
214
+
215
+
<!-- wp:list -->
216
+
<ulclass="wp-block-list"><!-- wp:list-item -->
217
+
<li>Environment-agnostic - It returns an array that defines dev, test, or prod environments.</li>
218
+
<!-- /wp:list-item -->
219
+
220
+
<!-- wp:list-item -->
221
+
<li>Testability - The consistent, central configuration promotes isolated (e.g. per-module) testing, easier swapping of dependencies and the assertion of pipeline setup (e.g. check if a config key is present).</li>
0 commit comments