Converting an Application from Fusebox 3 to Fusebox 5.5

Old applications never die, at least the one I am working on refuses to. It was written a while back and uses the Fusebox 3 framework. As we add more and more to it, it's getting more difficult to manage, so I decided to bite the bullet and convert it from Fusebox 3 to 5.5.

I had previously avoided upgrading to Fusebox 4 or 5 because there would have to be a lot of changes. Going from 3 to 4 wasn't easy. I did several conversions and they all took a long time and the limitations of Fusebox XML always meant that some clever stuff I had in my code had to be completely redesigned. The limitation of not being able to nest or tags in Fusebox 4 circuits was really a problem, as I had often done that in my fbx_switch (circuit) files which were written in CFML.

Don't get me wrong, I do like Fusebox XML now that I am used to it. If you start from there that's fine but converting something from Fusebox 3 is a bit different. Fusebox5.5 has one big advantage. It will let me use CFCs as circuits and they are written in CFML so I should be able to simply move the code from the fbx_switch to the CFC. That shouldn't be a problem.

So, yesterday I began the task and the first issue I came across was that in order to use CFCs as circuits I was forced to let Fusebox find my circuits for me. I started out deciding I was going to have a fusebox.xml file but that has no way to support CFC based circuits. So I got rid of the fusebox.xml and converted the first fbx_switch.cfm file to home.cfc.

The next issue was file placement. The original application had a number of directories each with it own module. In some cases it has subdirectories that make use of the nesting idea that was in four at the time. For example there is an Admin directory which has a number of subdirectories one for each area of the application.

This nesting of content is no longer done that way but there is a good reason for leaving the directory structure unchanged. I expect the conversion will take some time and the original application will continue to evolve in the meantime, so I want to eventually do a CVS merge of any changes. For that to work the locations of all the fuses really has to stay the same.

I consulted the documentation and then the guru and found that there is no way for the CFC based Fusebox to support that directory structure.

The original application also does not use MVC because in Fusebox 3 there was no big advantage from separating the application that way. I know Hal was preaching it, but at that time I thought it was really difficult and I didn't see any big benefit from the extra overhead.

I decided that eventually I do want to use MVC so it makes sense to go in that direction so I have created a controller directory in which to put the new CFC based circuits. Since I already had the framework installed on my machine, Step 1 was to create a new CVS branch and take one of the fbx_switch files and convert it to a CFC. In the short term I won't create a model or view as I just want the existing to code to work with minimum changes as a first pass. By the end of the day I had my first fuseaction working.

There were a number of wrinkles. The first was the surprise of seeing this error message:

This is just a case of RTFM and the answer is to set some Fusebox variables to turn on the no XML mode of operation and set the default page.

<cfset FUSEBOX_PARAMETERS.defaultFuseaction = "home.home" />
<cfset FUSEBOX_PARAMETERS.allowImplicitFusebox = true />

The second was that I was't seeing all my HTML. The original application makes heavy use of <cfsetting> in an attempt to avoid whitespace. There was obvoisly a difference between the old and new structure I had created and there was not enough <cfsetting> tags. Adding an extra one solved the problem but the whole lot will need sorting out. I generally now use <cfsilent> instead as I find it more reliable and easier to code.

I'll let you know how I get on.

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.