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
{{ message }}
Repository navigation
Commit 46f55c3
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: public/md-articles/architecture/configprovider-bootstrap-modern-php-applications.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,10 @@ class ConfigProvider
34
34
{
35
35
public function __invoke(): array
36
36
{
37
-
return [ /* ... */ ];
37
+
return [
38
+
'dependencies' => $this->getDependencies(),
39
+
'templates' => $this->getTemplates(),
40
+
];
38
41
}
39
42
40
43
public function getDependencies(): array
@@ -59,7 +62,7 @@ What each item means:
59
62
60
63
| Item | Meaning |
61
64
|---|---|
62
-
|`dependencies`| Used by the dependency injector (e.g. laminas-servicemanager) to construct every requested service. |
65
+
|`dependencies`| Used by the dependency injector (e.g. [laminas-servicemanager](https://docs.mezzio.dev/mezzio/v3/features/container/laminas-servicemanager/)) to construct every requested service. |
63
66
|`factories`| The factory builds the service. |
64
67
|`invokables`| The service is built with `new` directly. |
65
68
|`aliases`| Redirects to another service name. |
@@ -74,15 +77,19 @@ The ConfigProvider is automatically picked up by the framework during applicatio
74
77
2.**Read the configuration array** - A call similar to `$config = $container->get('config') ?? [];` reads an array of entries.
75
78
3.**Resolve item** - `$app->pipe()` is called to resolve one of the following: resolve the service name from the container, wrap the middleware if an array is provided, or call the closure or invokable object.
76
79
4.**Handle errors** - The error-handling middleware is the last one in the pipeline, to make sure it can handle any exceptions.
77
-
5.**Execute at runtime** - Laminas Stratigility iterates over the pipeline in the order it was registered. Each middleware can handle the request and return a response, or delegate execution to the next middleware in the pipeline, until a `ResponseInterface` is returned to the client.
80
+
5.**Execute at runtime** - [Laminas Stratigility](https://docs.laminas.dev/laminas-stratigility/) iterates over the pipeline in the order it was registered. Each middleware can handle the request and return a response, or delegate execution to the next middleware in the pipeline, until a `ResponseInterface` is returned to the client.
81
+
82
+
Below you can see how Mezzio and Dotkernel merge and use ConfigProviders to build the middleware pipeline and dependencies.
-**Centralized setup** - Instead of hardcoding bootstrap code, it's declared in a config provider so it's easy to read, change, or extend.
82
89
-**Modular** - Each package can ship with its own config without interfering with others.
83
90
-**Container-friendly** - Works well with frameworks using DI containers like Laminas ServiceManager, PHP-DI, or Pimple.
84
91
-**Standardized service definitions** - Consistent rules for object creation, separate from business logic.
85
-
-**Auto-Discovery** - In Laminas/Mezzio, the ConfigAggregator automatically loads and merges all ConfigProviders.
92
+
-**Auto-Discovery** - In Laminas/Mezzio, the [ConfigAggregator](https://docs.laminas.dev/laminas-config-aggregator/) automatically loads and merges all ConfigProviders.
86
93
Dotkernel is an exception: new ConfigProviders have to be added manually in `config/config.php`, because all the initial ConfigProviders required to install the applications are already injected.
87
94
-**Environment-agnostic** - Returns an array that defines dev, test, or prod environments.
88
95
-**Testability** - The consistent, central configuration promotes isolated (e.g. per-module) testing, easier swapping of dependencies, and assertion of pipeline setup (e.g. checking if a config key is present).
When the SVN commit of the file is made, the `$Id$` keyword will be replaced with text containing the file's SVN metadata, in a specific format.
21
+
2. Right click on the file, then follow Team -> Set Property...**Note**: *Set Property...* will not be active if you haven't first added the file to SVN: *Team*->*Add to Version Controller*
**Q: How do you set the svn:keywords property for a file in Aptana?**
30
-
A: Write the keyword marker (for example `$Id$`) in the file, then right click the file and follow Team -> Set Property..., select `svn:keywords`, and write `Id` in the text field.
36
+
A: Write the keyword marker (for example $Id$) in the file, then right click the file and follow Team -> Set Property..., select svn:keywords, and write Id in the text field.
31
37
32
38
**Q: Why is "Set Property..." not active when I right click the file?**
33
39
A: Set Property... will not be active if the file hasn't first been added to SVN.
34
40
Use Team -> Add to Version Controller before trying to set the property.
35
41
36
42
**Q: What happens to the $Id$ keyword after an SVN commit?**
37
-
A: After the SVN commit of the file, the `$Id$` keyword is replaced with text containing the file's SVN metadata, in a specific format.
43
+
A: After the SVN commit of the file, the $Id$ keyword is replaced with text containing the file's SVN metadata, in a specific format.
0 commit comments