Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 environments 1 application.cfm

Status
Not open for further replies.

hugstable

Programmer
Feb 20, 2006
65
US
I have an application and the app variables differ slightly from my hosting deployment environment versus my development environment..

can i use a cfif on my app.cfm page to fix this...

what would the cfif look like...

is this a HORRIBLE IDEA?
 
You could use the SERVER_NAME CGI variable to detect which server the code runs on.

<CFIF cgi.SERVER_NAME is "mydevbox">
<!--- Do something on the dev machine --->
<CFELSE>
<!--- Do something on the production box --->
</CFIF>

If the environments are different out of necessity, then, no, it's not a horrible idea. Configs will differ because of naming conventions, file locations, etc., so you need a way to handle them.

HTH,

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Or you could just have a different config file for each server, this is what I do.
I have all my global vars stored in a WDDX file, and I have a different file for each environment, the contensts of that WDDX file is then extracted into REQUEST scope. The WDDX file is of course in a non web accessible folder.

<!---------- in my application.cfm I have this ------------->

<cfinclude template="includes/global_variables.cfm">

<cfapplication name="#server_name#/#request.global.applicationname#" clientmanagement="Yes" sessionmanagement="Yes" SessionTimeout="#CreateTimeSpan(0,0,30,0)#">
<!-- end -->

<!------------ in my global_variables.cfm ----------->
<cfset live_servers = "<cfset dev_servers = "localhost,mydevdomain.com">
<cfif listfind(live_servers, server_name)>
<cfset suffix = "live">
<cfelse>
<cfset suffix = "dev">
</cfif>
<cfset encryptKey = ""><!--- the encryption key if used onthe wddx file --->
<cfsavecontent variable="request.config"><cfinclude template="../../secure/global_variables_#suffix#.wddx"></cfsavecontent>
<cfif encryptkey IS "">
<!--- don't decrypt if no encryptkey provided --->
<cfwddx action="WDDX2CFML" input="#request.config#" output="request.global">
<cfelse>
<!--- decrypt wddx packet --->
<cfwddx action="WDDX2CFML" input="#Decrypt(request.config, encryptkey)#" output="request.global">
</cfif>

Regards
--
Russ Michaels
CFDeveloper.co.uk
ColdFusion Developer community and FREE developer hosting

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top