title: ZF2 global config settings
body: <p>My goal is to have configuration settings shared and editable within each module in a Zend Framework 2 project. After research, I came to this: <a href="http://akrabat.com/zend-framework-2/injecting-configuration-into-a-zf2-controller/" rel="nofollow">http://akrabat.com/zend-framework-2/injecting-configuration-into-a-zf2-controller/</a> which worked great at first but after my application keeps expanding to more modules and more controllers, I don't appreciate this solution. Precisely, I don't appreciate having to "implement" interface, add SetConfig method and so on. Instead, I'd like to be able to just call on $GLOBALS or similar in my controller and get the parameter of interest. </p>
  
  <p>Say I have a file config.local.php with the following format:</p>
  
  <pre><code>    return array(
      'group1' =&gt; array(
          'key1' =&gt; 'value1',
          'key2' =&gt; 'value2',
      )
  
     'group2' =&gt; array (
          'subgroup' =&gt; array (
               'keyA' =&gt; 'valueA',
               'keyB' =&gt; 'valueB',
          ),
      )
  );
  </code></pre>
  
  <p>Right now, i'm following the tutorial above and after implemeting the ConfigAwareInterface in my controller, I get valueA using </p>
  
  <pre><code>$this-&gt;config['group2']['subgroup']['keyA']
  </code></pre>
  
  <p>I'm now hoping to just rather call $GLOBALS['group2']['subgroup']['keyA'] without the ConfigAwareInterface intermediate.</p>
  
  <p>I laid the following quick pseudo code to help me achieve that:</p>
  
  <pre><code>for every this-&gt;config as key =&gt; value 
      if $key is not array
          $GLOBALS[$key] =&gt; $value
      else 
          for every $value as $k =&gt; $v
              $GLOBALS[$key][$k] =&gt; $value
  </code></pre>
  
  <p>As ZF2 and php are new to me, I'm not completely sure I can have more than 1 index/nested keys for $GLOBALS but I can tailor my config file to avoid that.</p>
  
  <p>There are probably other logical mistakes above. But just to get the point. Now, is this the best way to go about global configuration or is there a better approach?</p>
  
  <p>Thanks in advance.</p>