Modifying FW/1 variables.framework Properties
FW/1 gives you a nice, clean way to manage framework configuration properties. They’re all wrapped up inside Application.cfc in a structure called variables.framework, you can read more about them here under Configuring FW/1 Applications.
Our applications often have a need to use different values for these properties, depending on which environment the application is running in (development, testing, staging, production etc). An example of this might be reloadApplicationOnEveryRequest, which we want as true in development, but false elsewhere else.
So our defaults (at the top of Application.cfc) might be to set the reload property as false:
1 2 3 4 5
These are good values for production, but we want to override them if we’re in development. Here’s how:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
You can see in the example above that we override the default values we set initially, so that if we’re in development mode we not only have the ability to reload the application (using a custom property called disableReloadApplication), but we also reload the application on every request.
2 things to note here, are that we can’t use setupRequest() for this, as it’s called too late by framework.cfc and won’t enable us to override any variables.framework properties. So instead we use onRequestStart(), which gives us the 2nd thing to watch out for, and that is that you must be careful to call super.onRequestStart(targetPath); at the conclusion of this method. Or you might get strange results.