I want to write a php application using Zend Framework 2 (just the beta 2 yet).
Because it’s going to be a collection of several webservices I decided to seperate it into different modules (with own databases).
Before starting to write the first module I want to write the code wich each module should need. For example the layout. Each module uses the same layout. That’s why I want to write it globally to improve the development process of single modules.
How can I provide defaults for each module globally? (e.g. layout, plugin, default database model, …)
In ZendFramework2 configurations from all modules are always merged.
Additionally there is a global config which can overwrite module-wise config.
So including a vendor module brings in a default configuration you can and should overwrite via your global config.
The global config may consist of multiple files making it easy to distinguish between modules-to-be-configured.
The first example I have is an article of akrabat about module configuration and overrides.
Another nice example of this pattern is Akrabat’s quickstart (https://github.com/akrabat/zf2-tutorial):
In the App module there is config for the basic routing, Views and the Layout are set up
In the Album module there is only the set-up for Album-specific things (e.g. dependency injection), the view and routing are used from the App-modules config.
You may decide to overwrite this config on a per-module basis or globally, in the default project layout your configs are placed like this:
/config/application.config.phpthe base configuration/config/autoload/*.config.phpmay be used to overwrite modules or app config (e.g. for local development)/module/[your-module]/config/[your-module].config.phpthe default configuration of your module/vendor/[vendor-module]/config/[vendor-module].config.phpa module you dropped in, but has definitions for it’s dependency injection. if it uses e.g. a database you want to overwrite some parameters in your/config/autoload/*