I created a Config Resource and a separate config.ini file for site
configuration params not related to Zend_Application :
<?php
class Resource_Config extends Zend_Application_Resource_ResourceAbstract {
protected $_config = null;
protected $_configFile = '';
public function init() {
$this->_configFile = APPLICATION_PATH . '/configs/config.ini';
return $this->getConfig();
}
public function getConfig() {
if ($this->_config === null) {
$this->_config = new Zend_Config_Ini($this->_configFile,
APPLICATION_ENV);
}
return $this->_config;
}
}
What do you guys think of this approach?
Thanks!
On Mon, Aug 17, 2009 at 5:03 PM, J DeBord <[email protected]> wrote:
> I'm just starting to figure out how Zend_Application works and I
> immediately had the same questions.
>
> If I move what was previously in my Zend_Config object stored in
> Zend_Registry to the application.ini file I use with Zend_Application, how
> can I access the values in the application.ini file. Things like my Amazon
> Web Services keys, google API key, etc?
>
> Thanks!
>
> Jason
>
>
>
>
> On Thu, Jul 23, 2009 at 7:25 PM, jasonzfw <[email protected]> wrote:
>
>>
>> Hi Ralf,
>>
>> I too have been wondering about this, and have concluded that moving the
>> configuration data into application.ini is the best approach, if for any
>> other reason because it consolidates the config data to a single file. I
>> don't see any harm in doing so, and the upside is one only has to deal
>> with
>> a single config file rather than wonder if multiple files exist.
>>
>> Would love to hear others' thoughts on this.
>>
>> Jason
>>
>>
>> Ralf Eggert wrote:
>> >
>> > So what is the best practice to handle this now? Move all config data
>> > used by Zend_Application to the application.ini and leave the rest (if
>> > any) in the config.ini? Or move all config data to application.ini? If
>> > the second, how can I access this config data throughout my application?
>> > Is the an object with the application.ini data which can be accessed
>> > with Zend_Registry or should I handle this myself?
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Best-practice-for-configuration-data-tp24600872p24630594.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>>
>