Alistair Knock
Alistair Knock

Reputation: 1836

Fusebox installation without access to webroot

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. 

Upvotes: 2

Views: 654

Answers (3)

Nathan Strutz
Nathan Strutz

Reputation: 8123

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.

Upvotes: 1

Adam Tuttle
Adam Tuttle

Reputation: 19834

In Application.cfc:

<cfscript>
    this.mappings = {}; //create a new structure to store app-specific mappings
    this.mappings["Fusebox"] = expandPath('./Fusebox'); //add mapping
</cfscript>

Upvotes: 0

Steve -Cutter- Blades
Steve -Cutter- Blades

Reputation: 5432

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.

Upvotes: 2

Related Questions