Featured post
php - Where to store application constants in Zend? -
i have few constants i'll need define application, example, site_key contain random key salt passwords.
i'm not sure should define those, though. thought of placing them in public/index.php seems bit messy. there specific place should go, according zend or something?
thanks
edit
i'm trying way: in application.ini
have this:
siteglobal.sitekey = "test"
and in bootstrap.php
file:
protected function _initglobals() { $config = $this->getoptions(); define('site_key', $config['siteglobal']['sitekey']); }
still, isn't working, when try echo site_key in controller this:
echo site_key;
it doesn't show anything. ideas?
in application, i'm combining both haim's , yeroon's approaches. i'm storing application constants in application.ini
, parsing them in bootstrap
, putting them zend_registry
.
so, in application.ini
constants.site_key = my_site_key
in bootstrap
protected function _initconstants() { $registry = zend_registry::getinstance(); $registry->constants = new zend_config( $this->getapplication()->getoption('constants') ); }
then can access these constants place in application (model, controller, etc.)
zend_registry::getinstance()->constants->site_key
- Get link
- X
- Other Apps
Comments
Post a Comment