Storing application config in an XML file

I’m working with a widely distributed project team at the moment, and one issue we have is that there are two development servers, a staging server and a production server, all with different settings. Until now we have been keeping all the different settings in the Application.cfm and checking the server name to work out which set to load on application start. Which is simple and effective, but not very elegant.

As my parts of the application develop, I’m starting to want to store even more settings information in a globally accessible manner. In my Googling, I come across some old threads on CFTALK about using a settings CFC to load these kinds of values, and also some other threads about using an XML file to store server-dependant settings. Hmmm… an idea is forming.

Then, by searching some more using the keyword “config CFC” instead of “settings CFC”, I come across an excellent open source project on Google Code by Jim Collins. Jim has taken the config.cfc concept and made it into a simple, reusable and get this – documented! set of files. You copy the CFC to your application, customise the XML file with your own variables, and copy the initialisation code example to your app – and Bob’s your proverbial. It’s simple, straightforward, easily understandable code and it certainly saved me some time coding it myself.

I emailed Jim to rave about it a bit, and he pointed me towards some discussion over the entire concept of using XML files for configuration. I’ve been missing out on all this kind of stuff lately because I’ve unsubscribed from both CFTALK and CFAUSSIE until things settle down a bit more. Anyway, Jim’s done a great job and he says “I hope the community finds it useful”.

Well, thanks Jim, I certainly have!

Previous post: How good markup makes your life easier

Next post: Hello to WordPress


About this entry