I load in static setting via an ini file. Ini file have the benefits
- of NOT being server by most web servers by default.
- easier to edit than XML
- even simplier than JSON
Setting get loaded in Application.cfc
void function setupApplication() output="false" {
...
application.stAdminSetting = application.loadini("admin\standard.ini");
...
}
Application.cfc has this as a function...
<cffunction name="loadini" output="false" returnType="struct">
<cfargument name="configfile" required="true" type="string" hint="reads from currentTemplate">
<cfscript>
var stResult = {};
var iniFilePath = "#GetDirectoryFromPath(GetBaseTemplatePath())##arguments.configfile#";
var stSection = getProfileSections(iniFilePath);
for(var section in stSection) {
var CurrentSection = evaluate("stSection.#section#");
var stData = {};
for(var i = 1; i <= ListLen(CurrentSection); i++) {
var key = ListGetAt(CurrentSection, i);
stData[key] = getProfileString(iniFilePath, section, key);
}
setvariable("stResult.#section#", stData);
}
return stResult;
</cfscript>
</cffunction>
The ini file can have any number of setting. In particular my ini file has:
[ws]
comment=http://xxxxx.com/resource/comment.cfc?wsdl
ior=http://xxxxx.com/resource/ior.cfc?wsdl
node=http://xxxxx.com/resource/node.cfc?wsdl
pref=http://xxxxx.com/resource/pref.cfc?wsdl
traffic=http://xxxxx.com/resource/traffic.cfc?wsdl
What kinds of things can I do to improve this?