Making FW/1 Dance: Customizing ColdFusion Frameworks
This post covers customizing FW/1 to use a custom directory structure. This post is part of a mini-series on Making Frameworks Dance: Customizing ColdFusion Frameworks.
I like how Rails 3 applications are setup. I wanted to keep the following directory structure when converting the application to ColdFusion.
Moving FW/1 to /lib
FW/1 is a single compenent that resides at /org/corfield/.
You can safely move /org inside of /lib.
The only reference you need to update is in /Application.cfc. In /Application.cfc, change
Moving FW/1 Application Folders to /app
Application folders are all of the folders I listed under the /app directory, which includes: controllers, layouts, model, and views.
FW/1 also has a services folder that we’re going to add to the /app folder.
FW/1 has a nice feature that easily allows you to move the application folders relative to the application root.
base – Provide this if the application itself is not in the same directory as Application.cfc and index.cfm. It should be the relative path to the application from the Application.cfc file.
In addition you can override the base directory for the application, which is necessary when the controllers, services, views and layouts are not in the same directory as the application’s index.cfm file. variables.framework.base should specify the path to the directory containing the layouts and views folders, either as a mapped path or a webroot-relative path (i.e., it must start with / and expand to a full file system path). If the controllers and services folders are in that same directory, FW/1 will find them automatically. If you decide to put your controllers and services folders somewhere else, you can also specify variables.framework.cfcbase as a dotted-path to those components, e.g., com.myapp.cfcs assuming that com.myapp.cfcs.controllers.Controller maps to your Controller.cfc and com.myapp.cfcs.services.Service maps to your Service.cfc.
The FW/1 wiki is refering to `variables.framework.base` within /Application.cfc. In order to move the application folders to /app we need to set this value.
Add the following to /Application.cfc:
FW/1 is a pleasure to dance with. It is by far the easiest ColdFusion framework to customize. It was designed with motion in mind. The only customizing was in /Application.cfc, which is where I’d expect to find it.
Other Frameworks in Mini-series
I’ll be covering multiple frameworks and the issues in getting them to work in the directory structure above. Each framework will be it’s own post. This post will be updated with links to all posts in the mini-series so you can easily jump to your favorite.