Inash,
J Debord's approach is pretty good, by creating a separate config.ini
file, you are effectively splitting the Zend_Application resources from
the config values that your models/services, or controller code might
use- which is good, b/c then you can see the distinction.
The application.ini file generally will contain any values that either
Zend_Application can use directly, or pass into Zend_Application resources.
You can also do something similar to the resource below by simply adding
a _initConfig in your Bootstrap file.
Also, in general, if you needed to access application.ini values, this
should work from within an action controller:
$this->getInvokeArg('bootstrap')->getApplication()->getOptions()
OR
$front->getParam('bootstrap')->getApplication()->getOptions()
Hope that helps,
Ralph
Inash Zubair wrote:
Hi.
Does any body have a best practice about this? I've also have a couple
questions to add:
- I'm unable to access the front controller from the action controllers
unless i get a reference to the bootstrap through the getInvokeArg.
- How can i access the global configuration (application.ini) more
conveniently through action controllers.
Cheers.
On Mon, Aug 17, 2009 at 8:31 PM, J DeBord <[email protected]
<mailto:[email protected]>> wrote:
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]
<mailto:[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]
<mailto:[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.
--
Inash Zubair