views:

168

answers:

3

Previously (and locally) I've placed the fusebox5 directory in the web root, and then applications from anywhere in the tree have been able to access it. I'd previously also used Application.cfm rather than .cfc.

In this environment I don't have access to the webroot and the FB files don't really need to be that far down anyway, so I had planned to store them alongside the applications. Am I right in thinking that index.cfm is overlooked if Application.cfc is in use (and therefore there's no point changing the cfinclude value to be eg. ../fusebox5/)? If so, how can I include the framework without having Fusebox in the root or in a mapping? Error is:

Could not find the ColdFusion Component or Interface fusebox5.Application.
+2  A: 

No, your app is still going to need index.cfm. What you'll need is a cf application mapping for Fusebox in your Application.cfc. Look at Ray Camden's Application.cfc template for an example of setting application specific mappings.

Steve -Cutter- Blades
A: 

In Application.cfc:

<cfscript>
    this.mappings = {}; //create a new structure to store app-specific mappings
    this.mappings["Fusebox"] = expandPath('./Fusebox'); //add mapping
</cfscript>
Adam Tuttle
The mapping will work, but if you are trying to extend a component in that mapping (fusebox5.Application) it will break. You can't create an instance of Application.cfc until it finds the extended component, but you can't find the extended component until you have a mapping to it. Fail.
Nathan Strutz
+1  A: 

You can run Fusebox 5+ in a subfolder of your app root. It just may not be the most obvious thing to make it work.

Unfortunately, you cannot create a dynamic mapping for extending Application.cfc because your Application.cfc has not yet been instantiated - you get a chicken vs. egg scenario. You can't create the mapping to Fusebox because your Application.cfc didn't start, you can't start your Application.cfc because it can't find the component it's supposed to extend.

THIS IS A BUG IN COLDFUSION 8. ColdFusion should look for mappings in this order:

  • Mapped folders from the CF Administrator
  • Sub directories off the current directory
  • Sub directories off the web root called

It does this when you use CreateObject(), but not when you use the Extends attribute on cfcomponent.

The easiest solution is to use your Application.cfc like you would for any application, then include fusebox from your index.cfm. Your folder structure would look like this:

/myapp/fusebox5/
/myapp/index.cfm
  -- consists of <cfinclude template="fusebox5/fusebox5.cfm" />

Your index.cfm file will not be ignored as long as you don't intercept the request with Application.cfc's OnRequest, or if you use OnRequest, make sure you include the intended target (which will almost always be index.cfm anyway).

If you want to not require index.cfm to do the include, you can have your Application.cfc's OnRequest method do the cfinclude.

<cffunction name="onRequest">
    <cfinclude template="fusebox5/fusebox5.cfm">
</cffunction>

You still may need an index.cfm so your web server won't give a directory listing or 404, but it's ok if the file is empty.

Nathan Strutz