Zend_Config is read-only if you did not set $ allowModifications to true at build time.
From Zend_Config_Ini::__constructor() docblock : -
/** The $options parameter may be provided as either a boolean or an array. * If provided as a boolean, this sets the $allowModifications option of * Zend_Config. If provided as an array, there are three configuration * directives that may be set. For example: * * $options = array( * 'allowModifications' => false, * 'nestSeparator' => ':', * 'skipExtends' => false, * ); */ public function __construct($filename, $section = null, $options = false)
This means that you will need to do something like this: -
$inifile = APPLICATION_PATH . '/configs/application.ini'; $section = 'production'; $allowModifications = true; $config = new Zend_Config_ini($inifile, $section, $allowModifications); $config->resources->db->params->username = 'test'; var_dump($config->resources->db->params->username);
Result
string 'test' (length = 4)
In response to the comment
In this case, you can simply extend Zend_Config_Ini and override the __construct() and __set() methods as follows: -
class Application_Model_Config extends Zend_Config_Ini { private $allowed = array(); public function __construct($filename, $section = null, $options = false) { $this->allowed = array( 'list', 'of', 'allowed', 'variables' ); parent::__construct($filename, $section, $options); } public function __set($name, $value) { if(in_array($name, $this->allowed)){ $this->_allowModifications = true; parent::__set($name, $value); $this->setReadOnly(); } else { parent::__set($name, $value);}