Logical Chaos Theory

Developing An Easier World…

ColdFusion Application Multi-Environment Configuration

A common problem that I and I’m sure many others have had in the development process of web applications is handling application configuration for different environments such as local development, staging, and production sites. For quite some time now I have had this problem licked in my ColdFusion applications by using a SettingsManager class I had wrote a couple years ago. I have just now decided to release it to the public for others to enjoy as well.

The syntax for using this settings manager is really simple as well. It can be initialized in the onApplicationStart method of your ColdFusion application’s Application.cfc file using the code below.

<cfset path = replace(getDirectoryFromPath(getCurrentTemplatePath()), ‘\’, ‘/’, ‘all’)>
<cfset application.settings = createObject(’component’, ‘com.logicalchaostheory.settings.SettingsManager’).init(path)>

Just add the code above and extract the contents of the zip file to the same directory as your Application.cfc file and thats it! To configure your different environments just edit the com/logicalchaostheory/settings/settings.xml file.

I have also considered releasing another ColdFusion class I have written that will use the settings configuration provided by the settings manager class and automatically setup ColdFusion administrator settings based on what environment the application is running from. For example, for a given ColdFusion application you might have two datasources, one custom tag, and an alias that all need setup. My installer class will take settings specified in the settings manager configuration file and automatically add them to the ColdFusion administrator (provided the application has access to the administrator API). If anyone is interested in obtaining this class please post a comment and I will get back with you about posting up the latest source code.

The source code for the SettingsManager class can be obtained here.




Categorized as ColdFusion

Leave a Reply