Migrating Legacy App to ColdBox using a SubDirectory (TIP 102)

I’m following the TIP 102 from L. Majano book to migrate a legacy app to ColdBox using a SubDirectory.

I followed step by step and more or less ‘worked’ :slight_smile: I mean I can finally run succesufully the CB home event at:

http://127.0.0.1:8080 (my local server)

and

http://127.0.0.1:8080/main/data

but I have some doubts about what is described at page 214:

‘Once the application has been generated, let’s copy the following files back into the webroot’:

  • Application.cfc
  • index.cfm
  • server.json
  • box.json

This really mean ‘copy’ or ‘move’ (cut/paste)? I’m asking because later book says ‘move’ the entire /app/coldbox folder’ (the CB library) and ‘move’ the box.json.

The legacy Application.cfc (on the webroot) with a copy/paste would be overwritten so it’s necessary make a temporary copy to later refactor as described in the following steps (in my case would be a huge refactoring since I have 1000 lines of code in cf tags :frowning:

Same will happen eventually for the legacy index.cfm on the on the webroot (I have some logic in there, probably should be moved into Application.cfc too)

So, if this is finally the structure of the folders:

+ /app (coldbox app) (if I understand correclty will still have the original /Application.cfc and index.cfm and will not have anymore the /coldbox lib
+ /coldbox (CB lib)
+ Application.cfc (this will be a join of the legacy webroot/Application.cfc and the modern Application.cfc we copied into
+ index.cfm (this will be a join of the legacy webroot/index.cfm and the app/index.cfm merged and ideally just the default CB index.cfm
+ server.json
+ /any old legacy folder or file
+ box.json (I see that this not mandatory and I can leave it in the /app folder)

***Now the questions and comments:

******** in my legacy base Application.cfc in the webroot ***********

// I had to change this:

this.javaSettings = {
loadPaths : [ expandPath( “./app/lib/java” ) ], // not just expandPath( “./app/lib”
loadColdFusionClassPath : true,
reloadOnChange : false
};

// I also had to add line below otherwise the ColdBox Library on the webroot was not found:)

this.mappings[ “/coldbox” ] = expandPath( “/coldbox” )

*********** in the Application.cfc in the ‘app’ (CB) folder ***********

COLDBOX_APP_ROOT_PATH = getDirectoryFromPath( getCurrentTemplatePath() ); // this now point to /app folder

// mapping to the CB library should be updated to something like this:

this.mappings[ “/coldbox” ] = expandPath( “/coldbox” )

// and not this.mappings[ “/coldbox” ] = COLDBOX_APP_ROOT_PATH & “coldbox”; // because this below would point to /app/coldbox but we moved that (cut/paste) to the webroot

As said I did this working since I can load:

http://127.0.0.1:8080 (my local server) This will load the default main layout/view (I see the ColdBox Welcome Page)

and

http://127.0.0.1:8080/main/data This will load the JSON example data

but I have had some strange behaviour with the links since

http://127.0.0.1:8080/app/app/tests/index.cfm there is a double /app/app that does not seem correct to me (link is broken!)

I installed CBDebugger but when I fwreinit the ap:

http://127.0.0.1:8080/app/cbdebugger this will not load (EventHandlerNotRegisteredException)

http://127.0.0.1:8080/cbdebugger neiher this (Page Not Found)

I have the module inside {{webroot}}\app\modules\cbdebugger

Finally, another doubt is about box.json, book suggests to move it on webroot and update the installation path

How should I change these or other properties if I move the box.json file to the webroot?

“installPaths”:{
“coldbox”:“coldbox/”,
“testbox”:“testbox/”,
“cbdebugger”:“modules/cbdebugger/”
}

Thanks for any help

Giampiero

Hi gpbonifazi

I’m debating which way is best for legacy migration and even the tips are not really clear. Did you manage to come up with a working solution for this?

So far I’ve been through -

Brad Woods method - coldbox-legacy-app-demo
Dan Cards method - coldbox-existing-code-blog

And just discovered Luis Majanos tip 102

I’ve not yet made up my mind and would appreciate your take!

Thanks and Regards

Tony Legge