Compared to Zend Framework 1 (ZF1) the way the configuration files are handled in ZF2 have changed completely. ZF1 relied on .ini files that can be processed with the native PHP function parse_ini_file(). Advantages: all configuration settings for production, staging and development are collected on a single page and data are only overwritten if desired. Disadvantage: production data end up in a development environment and are part of the repository. In ZF2 two configuration files exist, one called global.php and one called local.php. Both return an array and both are merged using array_merge_recursive() in an order defined by the application config. The combined configuration file can be cached so there is no immediate need for optimization. Be careful with adding arrays as part of the configuration, the keys have to be unique.
Setting an environment is inevitable if config settings depend on it. This can be tricky. The .htaccess file is not the place to set it (part of repository) and developers do not always have the luxury of httpd.conf access. For XAMPP users place this line:


in the in httpd-vhosts.conf in the VirtualHost section. If the environment is not set, the code should assume “development” and not “production” as in the ZF2 documentation.

See latest commit for all code changes.