ZF-5973: iterating over a Zend_Config

Issue Type: Bug Created: 2009-03-09T10:13:03.000+0000 Last Updated: 2009-03-10T06:48:03.000+0000 Status: Resolved Fix version(s): Reporter: Brice Laurencin (brisssou) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Config

Related issues: Attachments:


having a configuration file like this one :

<pre class="highlight">
<?xml version="1.0" encoding="UTF-8"?>

logtimestamppriorityNameprioritymessageuser<a>php://output</a>this code fails quite well :

<pre class="highlight">
$config = new Zend_Config_Xml('/config/log.xml');
foreach ($config->writer as $writerCfg) {
    $writers[$writerCfg->name] = InnoPrim_Log_Writer_Factory::build($writerCfg);

the first writerCfg element is "file", which quite not what I asked for.

did I do something wrong?


Posted by Brice Laurencin (brisssou) on 2009-03-10T06:13:10.000+0000

ok, a new to do it is describe here:…

Posted by Ben Scholzen (dasprid) on 2009-03-10T06:30:17.000+0000

The reason for this is, that the second level is seen as section-level, which cannot be folded into an array. You have to make your config look something like this:

<pre class="highlight">
<?xml version="1.0" encoding="UTF-8"?>

logtimestamppriorityNameprioritymessageuser<a>php://output</a>Then you can iterate over them like this:

<pre class="highlight">
foreach ($config->writers->writer as $writerCfg) {
    $writers[$writerCfg->name] = InnoPrim_Log_Writer_Factory::build($writerCfg);

Posted by Brice Laurencin (brisssou) on 2009-03-10T06:47:54.000+0000

I tried to iterate it but iterated on $config->writers

sorry to have bothered you.

Thanks a lot for you help!

Have you found an issue?

See the Overview section for more details.


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

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