如何在 zend 框架安装中获取 Controller 文件中已加载的选项,而不创建新的 Zend_Config([ ** ]);实例。
最佳答案
一旦 Zend_Application
读取 application.ini
,这些值就会存储在 bootstrap 中。
您可以在任何地方访问它们,无需访问磁盘或使用注册表:
$front = Zend_Controller_Front::getInstance();
$bootstrap = $front->getParam('bootstrap');
if (null === $bootstrap) {
throw new My_Exception('Unable to find bootstrap');
}
$options = $bootstrap->getOptions();
在 Controller 中,您还可以使用 $this->getInvokeArg('bootstrap');
关于zend-framework - 在 Controller 中获取加载的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3556843/