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? (eg 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 (eg 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.php
the base configuration
/config/autoload/*.config.php
may be used to overwrite modules or app config (eg for local development)
/module/[your-module]/config/[your-module].config.php
the default configuration of your module
/vendor/[vendor-module]/config/[vendor-module].config.php
a module you dropped in, but has definitions for it's dependency injection. if it uses eg a database you want to overwrite some parameters in your /config/autoload/*
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.