title: How to retrieve parameters from Zend application.ini file during the session?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5699844/how-could-read-application-ini-on-controller-using-zend-framework">How could read application.ini on controller using zend framework</a>  </p>
  </blockquote>
  
  
  
  <p><code>application.ini</code> is a configuration file in ZF. I have there some more settings than just those defaults that ZF manual writes about. But how may I retrieve those parameters from it from my action controllers for example? And where is it better to store this config during the session?</p>
  
  <p>The <code>Bootstrap_Abstract</code> class has <code>getOptions()</code> method which returns a simple php array of read <code>application.ini</code> file:</p>
  
  <pre><code>$app = new Zend_Application(APPLICATION_ENV, '/application.ini');
  $config = $app-&gt;bootstrap()-&gt;getOptions();  // $config is a php array of application.ini
  </code></pre>
  
  <p>And I'd like to get element form it oop-style:</p>
  
  <pre><code>$param = $config[one][two];  // vs.
  $param = $config-&gt;one-&gt;two;  // like this
  </code></pre>
  
  <p>ZF has <code>Zend_Config_Ini</code> class which reads <code>.ini</code>'s and returns exactly the ArrayObject. But I'd like to avoid reading <code>application.ini</code> with <code>Zend_Config_Ini</code> one more time after <code>Zend_Application</code> has anyway already read it. But <code>Bootstrap</code> or <code>Zend_Application</code> classes don't provide some automatic creation of ArrayObject from <code>application.ini</code>.</p>
  
  <p>And the second, where may I store this $config then? In <code>Zend_Registry</code>?</p>
  
  <pre><code>Zend_Registry::set('config', $config);
  </code></pre>
  
  <p>And then in my some action controller I retrieve it:</p>
  
  <pre><code>$config = Zend_Registry::get('config');  // I retrieve config
  $param = $config-&gt;one-&gt;two;              // I retrieve parameter from it and use it
  </code></pre>
  
  <p>But it seems a little inefficient: I have one copy of <code>application.ini</code> in the <code>Bootstrap</code> in the form of usual php array and one copy of the same <code>application.ini</code> but in the form of ArrayObject in <code>Zend_Registry</code> too. And have to make two steps to get a parameter from my config. How can I solve this problem more efficiently? </p>