[coldbox-4.3.0] Wirebox, scanLocations issue

Hi

I am first-time deploying a newly-built app from my DEV server to a PROD environment.

In my Wirebox.cfc I have needed to make this nasty hack:

// Package scan locations

//scanLocations = [getAppMapping() & “.services”], // DEV

//scanLocations = [“services”], // PROD

// Nasty, but it will do for now so we can deploy to prod

scanLocations = (cgi.SERVER_NAME is “myProdDomain.org” ? [“services”] : [getAppMapping() & “.services”]),

Obviously I don’t want to put any conditional logic in here and would prefer to set a variable in the Coldbox.cfc and to read that variable here. Is that possible? It seems to me that the settings in Coldbox.cfc aren’t available in the Wirebox.cfc. Can they be injected in some way?

Firstly, your WireBox binder does have access to your ColdBox settings via getProperties() and getProperty().

Secondly, the fix is even better than that. It sounds again like your dev environment is not matching your production environment in terms of folder structure which makes stuff like this a pain. I always recommend mirroring the same setup on dev and production so you don’t get bit. Nonetheless, the fix is to create an application-specific mapping in your Application.cfc called whatever you want. Either “/root” or “/yourAppName” and point it dynamically to the folder that the ColdBox app lives. Now, in your config you can always use that mapping to reference the root of the product without having to worry about whether or not it’s in a folder.

scanLocations = [“root.services”],

Use this even for custom exception templates, or even log folders. Since the /root mapping (or whatever you call it) always points to the folder that the app lives in, it makes all your code portable.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

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

Hi Brad

I hear (and agree with) what you say about having a consistent directory structure across environments. However, we are where we are for the moment :frowning:

I have tried various permutations of your suggested solution and I must have misunderstood because I can’t get it to work. Can you help me with a specific example?

As mentioned earlier, on Dev the structure is:

myApp location
/Applications/ColdFusion11/cfusion/wwwroot/myApp/

Coldbox files
/Applications/ColdFusion11/cfusion/wwwroot/Coldbox/

And on Prod it is:

myApp location
/home/myAppName/public_html/

Coldbox files
/home/myAppName/public_html/Coldbox/

My Application.cfc currently looks like this:

COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() );
COLDBOX_APP_MAPPING = “”;
COLDBOX_CONFIG_FILE = “”;
COLDBOX_APP_KEY = “”;

What do I need to change in the Application.cfc in order to not have to mess about with conditionals for the Wirebox.cfc?

this.mappings[ ‘/root’ ] = COLDBOX_APP_ROOT_PATH;

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

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

Okay, got it! Thanks.