how to access the configuration data from within a controller action?
I have place this on my app开发者_运维问答lication.ini file:
contact.email.address = "my.mail@bla.org"
contact.email.name = "Test Name"
Then on my index controller action I have done:
$configOptions = $this->getInvokeArg('bootstrap')->getOptions();
$contactAddress = $configOptions->contact.email.address;
$this->view->contact = $contactAddress;
On my view I have:
var_dump($this->contact);
but I'm receiving NULL.
What am I missing ?
In your controller, I think you want:
$configOptions = $this->getInvokeArg('bootstrap')->getOptions();
$contactAddress = $configOptions['contact']['email']['address'];
$this->view->contact = $contactAddress;
You can use:
$configOptions = new Zend_Config($this->getInvokeArg('bootstrap')->getOptions());
$contactAddress = $configOptions->contact.email.address;
$this->view->contact = $contactAddress;
精彩评论