Question

I've got parameters I'm currently setting in ApplicationSettings.cfm and ThisSettings.cfm that I'm including into the Application.cfc. I want to keep these settings separate from the source code, because they contain environment specific information. I currently gitignore these files and paste sample settings in the comments above where I include them. Is there a better way of doing this?

Was it helpful?

Solution

There's two approaches spring to mind.

  • we create a ApplicationSettings.cfm.template and drop that into source control, but ignore the real AplicationSettings.cfm file. Any developer getting the code out for the first time copies ApplicationSettings.cfm.template to ApplicationSettings.cfm and edits to suit.

  • the other approach is to write code to read from a .properties file and put them outside of your codebase. That way the config files are pure config. It also means that updating the codebase in production is less error-prone as the config isn't in the same place as the code (we have hundreds of deployments, so this is very important to us). Our codebase reads from ../conf/config.properties, so it's relative to the codebase but not in the same place. Here's a very simple example of setting application-scope properties from a properties file:

        var e=props.propertyNames()
        for(e=props.propertyNames();e.hasMoreElements(); ){
            var key = e.nextElement();
            application[key]=props.getProperty(key);
        }                           
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top