I have a application.ini like this
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[database]
resources.db.adapter = PDO_MYSQL
resources.db.params.dbname = "ccgss"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.hostname = "localhost"
resources.db.isDefaultTableAdapter = true
[layout]
layoutPath = APPLICATION_PATH "/layouts"
layout = default
contentKey = "content"
By default, zend framework loads the [production]
section. How do I load automatically the others sections?
Additionally
How do I change the environments between staging
, testing
, development
and on?
To switch your application's environments between production, development, etc. simply set the variable to appropriate value in your .htaccess
file:
SetEnv APPLICATION_ENV development
If you'd like to auto-load your own resource plugins from the bootstrap, you can do that by just tacking it onto the resources
array:
resources.myplugin.param1 = "myvalue"
Don't forget to add your plugin's namespace and directory path to the pluginsPath
value as well, or ZF won't know where to look:
pluginPaths.My_Resource_Namespace = "My/Namespace/Folder"
Finally, if you want to acces values in your config file without using a resources
plugin, you can load the file using the Zend_Config_Ini class:
$config = new Zend_Config_Ini('/path/to/config.ini', 'staging');