RE: [coldbox:16322] Re: Dynamic Configuration Settings

I think you may be over complicating it :slight_smile: Basically, the main configure() method of your config file is executed as one of the first things that the framework does when it begins loading up. Then, the environment is immediately detected, and the proper environment override is executed next. Now that you have all the settings loaded for the correct environment, the framework continues to load the rest of it’s serves and aspects.

If all you want to do is have some settings which are different for dev or stage, simply put the production settings in your main configure() method. Then set up a regex in the environments struct for dev and stage (or provide a detectEnvironment() method to use whatever means of detection you prefer). Then in your dev() and state() methods (or whatever you choose to call your environments) simply override whatever settings you wish to be different. Remember, the settings are just a giant struct of variables, so you can perform any CFML you wish including basic set statements to overwrite a production setting with a dev one.

That’s it. No interceptors, or call to setSetting() are required. There are interception points for afterConfigurationLoad() if you want to really get funky, but if simple environment control is what you’re after, that is doable straight from your config. Note, ColdBox used to use an interceptor for environment control, but that was pre 3.x.

Here’s a blog post from John Whish with some examples of how it works now:
http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/coldbox-environments-using-machine-name-279

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com