Using Application-Specific Mappings With ColdBox
Last night I had a little time on my hands and decided to start a project I'd had on the backburner for a while (hint, hint). While setting up Coldbox, I wondered: Why not use application-specific mappings to reference the right framework versions? You might remember I had made a (short) series on refactoring Coldbox, Coldspring and Transfer for this exact reason. However, reading the Jedi's Transfer adventures made me realize that being on ColdFusion 8 meant that I could have these specific mappings, rather than refactoring the frameworks. I ran into an issue or two, however, and here's how I got rid of them.
The first thing that caused issues was the fact that Coldbox's Application.cfc extends a component in the Coldbox framework folder. Since you can't put any code before the component declaration in a .cfc, this would normally be a no-go for using application-specific mappings. Since version 2.6.0, however, Coldbox comes with an Application_noinheritance.cfc file. This alternate Application.cfc file doesn't extend coldbox.system.coldbox, instead it bootstraps the framework while initializing the component. This gives us more than enough time to specify our own mappings.
The first thing we need to do is rename our Application_noinheritance.cfc file to Application.cfc (replacing the original one). Then, we can specify our mappings.
Our own, custom mappings
<cfset this.mappings[ "/coldbox" ] = expandPath( "/frameworks/coldbox_2_6_1" ) />
<cfset this.mappings[ "/coldspring" ] = expandPath( "/frameworks/coldspring_1_2" ) />
<cfset this.mappings[ "/transfer" ] = expandPath( "/frameworks/transfer_1_1" ) />
<!---
And the rest stays the same.
--->
As you can see, I've setup mappings for all three frameworks I'll be using. Notice I use expandPath() to return a platform-specific absolute path. Since I know my frameworks are located on the web root, I can pass in the logical paths to them.
I know this solution is only compatible with ColdFusion 8, but the great thing is that downgrading is only a little refactoring away! The gain for CF8 users, however, is great: no need to refactor your frameworks!

