Re: Class initialization using ini file

From: Date: Mon, 05 May 2003 11:09:25 +0000
Subject: Re: Class initialization using ini file
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-5232@lists.php.net to get a copy of this message
Daniel Garcia wrote:
Hi, As a PEAR newbie user, I found different approaches to initializa the classes: Some are initialized passing variables as constructor parameters, while others can use an .ini file (which can be overriden when the class is instantiated). I find that using an .ini file is very convenient, since all the class initialization parameters can be in one separate file, and all the classes can be initialized with a loop (e.g. with the nice technique found in http://devel.akbkhome.com/peardoc2/package.html.html-template-flexy.configuration.html). In order to use the "ini file technique" for other classes that don't allow it, the only way I can think of is the class being extended, with the initialization being handled in that extended class. If anyone can think of a better approach, I'd like very much to hear it.
Actually it's more dependant on the PEAR::getStaticProperty('Package_Name', 'options'); the fact that the example use ini files is really just thats the easiest way to generate arrays.. I'm investigating wddx as a long term more flexible replacement on my projects. - advantages of xml without the parsing headache.. What you may find though is that some packages are more suited to 'application defaults' than others. Although it would be nice if more packages supported the getStaticProperty() - which has the benifit of not having to have the class loaded to set it's defaults.. Your best bet is to patch the classes and send the authors patches and see what they think.. Regards Alan
Just some thoughts... -- Daniel


« previous php.pear.general (#5232) next »