2010年1月12日星期二

Re: [fw-mvc] Manage multiple config file paths with Zend_Application

As Jon said, multiple configuration files will be supported by Zend_Application in Zend Framework 1.10 and I think that's a good point as it would allow developers to split there configuration into multiple config files if they want.

The second point is to know if it remain interesting to add the possibility to define a config file for a particular resource. That's the workaround I used for now using the Zend_Application _loadConfig method in my resource classes and calling setOptions with the options loaded from Zend_Config. Then, I just have to specify in my application.ini :
resources.navigation.resourceFile = APPLICATION_PATH "/configs/navigation.ini"

Regards.


On Tue, Jan 12, 2010 at 9:58 PM, prodigitalson <ant.cunningham@gmail.com> wrote:

I only seperate out my routes from the primary configuration (though i supose
if i was uning config for nav or forms i would want separate files for those
as well). But i also have two tiers of config, application level and module
level. So i have a application.xml and routes.xml in application/configs and
then i have a module.xml and routes.xml in /application/modules/*/configs.

I implemented all this with application resources as opposed to extending
Zend_Application and personally i dont see the benefit of passing multiple
files to Zend_Application when the files in question are resource specific
(and in my case also module specific). However, i do agree that having
everything in a single file gets insane pretty quickly so there should be
some sort of default implementation for splitting these up by
resource/module/etc.. :-)


Hector Virgen wrote:
>
> Good point, once loaded by Zend_Config they can be merged even if they are
> of different types.
>
> --
> Hector
>
>
> On Mon, Jan 11, 2010 at 9:38 AM, Loïc Frering
> <loic.frering@gmail.com>wrote:
>
>> Indeed, I encountered the same problem for my routes. An external config
>> by
>> resource seems also to be a good workaround !
>>
>> By the way, I agree with the additional root elements but having XML and
>> INI merged is possible since merge is a Zend_Config functionality.
>>
>>
>> On Mon, Jan 11, 2010 at 6:27 PM, Hector Virgen <djvirgen@gmail.com>
>> wrote:
>>
>>> I'm with you on multiple configs. However I'd prefer my configs to be
>>> independent instead of merged.
>>>
>>> For example, for navigation I prefer an XML config while for
>>> application.ini I prefer INI. I also don't want to add additional root
>>> elements (<resources><navigation>...) to my nav xml.
>>>
>>> I ended up creating my own navigation resource that accepted a config
>>> file
>>> and config section to use. This worked out well for me.
>>>
>>> Also, if you make a lot of routes, it would be nice to use a routes.ini
>>> (or routes.xml) instead of placing them all in application.ini.
>>>
>>> If the existing resources had support to load their options via an
>>> external config this would be great :)
>>>
>>> --
>>> Hector
>>>
>>>
>>>
>>> On Mon, Jan 11, 2010 at 9:21 AM, Loïc Frering
>>> <loic.frering@gmail.com>wrote:
>>>
>>>> Ok, that was the solutions I considered as this functionality does not
>>>> seem to be implemented. I wanted to be sure I didn't missed something.
>>>>
>>>> Here is the solution I choose : extending Zend_Application to support
>>>> an
>>>> array of config file paths in constructor or a directory of config
>>>> files
>>>> using the merge method of Zend_Config as mentioned by Andreas.
>>>>
>>>> I think it could be interesting to create a Jira entry as this
>>>> functionality could be really useful.
>>>>
>>>> Thanks for your responses.
>>>> Loïc.
>>>>
>>>>
>>>> On Mon, Jan 11, 2010 at 4:33 PM, Jurian Sluiman <
>>>> subscribe@juriansluiman.nl> wrote:
>>>>
>>>>> As far as I know there are three options you have:
>>>>>
>>>>> 1) Create your own navigation resource, overloading the zend
>>>>> navigation
>>>>> resource. It supports an additional parameter (e.g. configPath) and is
>>>>> able to
>>>>> load that config as its own Zend_Config instance
>>>>>
>>>>> 2) Extend Zend_Application to be able to pass an array of config files
>>>>>
>>>>> 3) Merge configs manually.
>>>>>
>>>>> I use the third option for my multiple website application. Each
>>>>> website
>>>>> (index.php) has it's own config file which is merged with the
>>>>> application's
>>>>> config file. The merged instance is passed to the Zend_Application
>>>>> constructor.
>>>>>
>>>>> --
>>>>> Jurian Sluiman
>>>>> CTO Soflomo V.O.F.
>>>>> http://soflomo.com
>>>>>
>>>>> On Monday 11 Jan 2010 16:19:13 Loïc Frering wrote:
>>>>> > Hi,
>>>>> >
>>>>> > I would like to separate my application configuration into multiple
>>>>> ini
>>>>> > files. It seems that it is not possible for now as Zend_Applicator
>>>>> only
>>>>> > accepts a string path to a config file, a Zend_Config object or an
>>>>> array of
>>>>> > options.
>>>>> >
>>>>> > Is this limitation known ? Maybe I missed something... I'd
>>>>> particularly
>>>>> > like to separate my navigation resource configuration which is quite
>>>>> > verbose from the rest of the configuration.
>>>>> >
>>>>> > If this functionality seems pertinent, I could create an Jira entry
>>>>> for
>>>>> > that
>>>>> >
>>>>> > :)
>>>>> >
>>>>> > Regards.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Loïc Frering
>>>> 128, rue Marius Berliet
>>>> 69008 Lyon
>>>> 0 954 954 786
>>>> 06 48 08 67 79
>>>> loic.frering@gmail.com
>>>>
>>>
>>>
>>
>>
>> --
>> Loïc Frering
>> 128, rue Marius Berliet
>> 69008 Lyon
>> 0 954 954 786
>> 06 48 08 67 79
>> loic.frering@gmail.com
>>
>
>

--
View this message in context: http://n4.nabble.com/Manage-multiple-config-file-paths-with-Zend-Application-tp1011277p1012479.html
Sent from the Zend MVC mailing list archive at Nabble.com.




--
Loïc Frering
128, rue Marius Berliet
69008 Lyon
0 954 954 786
06 48 08 67 79
loic.frering@gmail.com

没有评论: