There are quite a few other application frameworks for ColdFusion out there, so why write another one? This is a very good question and in this blog post i’ll try to give you an answer and a brief overview of blade.

Why write another application framework?

I like the way how conventions work. There are a few rules you have to follow and behind the scenes the magic will happen. That’s why i really love FW/1. No need to write Xml configuration files such as in ModelGlue nor read over 600 pages of documentation such as in ColdBox. Just place your controllers in the controllers and the services in the services directory. It couldn’t be easier!

However, there are some things which FW/1 have not built in, since FW/1 is a small, lightweight MVC framework. Nothing more. BUT: The real worlds weight is far from “light”. So i’ve been digging around for an existing application framework but have nothing found which suite my needs of

  • MVC
  • built in ColdFusion ORM
  • BeanFactory
  • Validation
  • convention based
  • easy to learn and use
  • rapid development

I think the only way to go before blade was cfWheels. But I don’t like how cfWheels pushes you to over-simplify your code (such as scopeless variables).

Overview of blade

Installation

Download the zip file from RIAForge und unpack it. You will get three different directories:

  • blade (the application framework - see description below)
  • samples (sample applications)
  • skeleton (an empty application skeleton)

To install blade, copy the blade directory to your webroot.

The Framework

  • hyrule (the hyrule validation framework)
  • org (FW/1)
  • wirebox (the WireBox IoC framework)
  • Application.cfc
    The Application.cfc extends Sean Corfield’s FW/1, adds the BeanFactory and some functionality for validation purposes. You have to extend this CFC instead of FW/1.
  • Binder.cfc
    The Binder.cfc is used from within the Application.cfc and configurates WireBox how load your beans, controllers, models and services.
  • Injector.cfc
    The Injector.cfc adds the getBean() and containsBean() method to the WireBox Injector. Those methods are needed by FW/1.
  • Model.cfc
    The Model.cfc is a Wrapper for all ColdFusion ORM functions and your model cfc’s have to extend this object. This Wrapper adds the ability to inject any objects into your model cfc’s.
  • ValidationResult.cfc
    The ValidationResult.cfc is needed by the Application.cfc to simplify the validation process.
  • mappings.cfm
    You will have to cfinclude this file into your Application.cfc. It will create the mappings for the frameworks used inside of blade.

How to load blade

To load blade, just extend the blade.Application class and cfinclude the mappings.cfm:

<cfcomponent output="false" extends="blade.Application" hint="Applikationskomponente">
  <cfinclude template="/blade/mappings.cfm" />
</cfcomponent>

See the FW/1 docs for a deeper look into the framework configuration. Please note, that the setupApplication and the setupSubsystem functions are used by blade. So if you want to customize these, make sure you call super.setupApplication() or super.setupSubsystem(argumentCollection=arguments) from within them first:

<cffunction name="setupApplication" returntype="void" access="public" output="false" hint="Wird beim Applikationsstart ausgeführt">
  <cfset super.setupApplication() />
  ... do your own stuff ...
</cffunction>

The “model” directory

blade automatically threat all (not recursive!) of your objects in the “model” directory as transients. So you have the ability to store all of your ColdFusion ORM entities in this folder. Please make sure your entity objects extend the base model class of blade.

<cfcomponent accessors="true" output="false" persistent="true" extends="blade.Model" hint="Model">
...
</cfcomponent>

If you wan’t to inject a model cfc, just inject it with the id “cfcNameModel”.

<cfproperty name="userModel" inject="id:userModel" />

The “beans” directory

All of your objects in the “beans” directory will be recursively loaded and WireBox will store them as singletons. If you wan’t to inject your bean objects into your controllers, services, or model cfc’s please note, that the id of the object will be the reverted path inside of the beans directory. A bean called “profileChar” which is stored inside of the beans/util directory will get the id “profileCharUtil”.

  • beans
    • util
      • profilechar.cfc
<cfproperty name="profileChar" inject="id:profileCharUtil" />

That’s it! For a deeper look into the framework, see the samples directory of the download.