I agree that this is harder in ZF than it should be, I hope this is an area that will be improved in future versions.
At the same time, itβs quite easy to merge two configuration files with Zend_Config, and this is something you can take advantage of. If you open public/index.php , you will see a section below where it creates an instance of Zend_Application. By default, the second parameter is the full path to your configuration file, but instead you can pass an existing Zend_Config object. Thus, you create two configuration objects: application.ini and environment.ini (call it what you want), merge them together and then pass them to Zend_Application:
$config = new Zend_Config_Ini( APPLICATION_PATH.'/configs/application.ini', APPLICATION_ENV, array('allowModifications' => true) ); $environment = new Zend_Config_Ini( APPLICATION_PATH.'/configs/environment.ini', APPLICATION_ENV ); $config->merge($environment); $application = new Zend_Application(APPLICATION_ENV, $config); $application->bootstrap() ->run();
With this approach, you save all the standard materials in application.ini and move the database material to environment.ini. Then you save application.ini in the source control, add environment.ini to gitignore / svn: ignore it and create a dummy environment.ini.dist file that your other developers can use to configure their local projects.
Note. If you commented on the require_once calls in the ZF library files for performance reasons, you may need to run some of the Zend_Config classes in public / index.php to make this work. This should be obvious from the mistakes.
source share