ZF-6345: Ability to get at Zend_Config object?

Issue Type: Improvement Created: 2009-04-19T13:26:32.000+0000 Last Updated: 2009-09-18T19:20:41.000+0000 Status: Resolved Fix version(s): - 1.9.2 (25/Aug/09)

Reporter: Rob Allen (rob) Assignee: None Tags: - Zend_Config

Related issues: - ZF-6246



It would be nice if you could get at the Zend_Config object that Zend_Application loads from within the bootstrap object. Seems a shame to have to load it twice.


Posted by -.- (campasau) on 2009-05-11T06:06:37.000+0000

You don't have to load it twice. Just do this:


<pre class="highlight">
  $config = new Zend_Config($application->getOptions());

Posted by Ingo Theiss (itheiss) on 2009-06-26T04:18:47.000+0000

You canĀ“t blindly use $application->getOptions(), because the Zend_Config object is convertet to an array and than gets passed to $application->setOptions(array $options). ALL array keys are converted to lowercase!

public function setOptions(array $options)
    $options = array_change_key_case($options, CASE_LOWER);

If you are using camelcase in you config you are lost....

Posted by Rob Allen (rob) on 2009-07-05T03:16:34.000+0000

This has just bitten me and is a right pain.

It only affects the toplevel keys though, so one workaround is to put all the rest of your configuration within a top level key such as "app".

Posted by Rafael Machado Dohms (rdohms) on 2009-07-24T04:56:51.000+0000

This same issue is beign discussed here and a patch is beign analysed to see if its worth implementing, performance-wise.

Posted by Rafael Machado Dohms (rdohms) on 2009-09-18T19:18:44.000+0000

After r17801 options are no longer stored with flattened keys, thus creating a Config File with the suggestion mentioned in the first comment is now a viable solution to the problem.

<pre class="highlight">
$config = new Zend_Config($application->getOptions());

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.