ColdBox Quick Start Guide


ColdBox is a “ColdFusion (CFML) Conventions Based MVC Framework. It provides a set of reusable code and tools that can be used to increase your development productivity as well as a development standard for working in team environments” – http://www.coldbox.org/.

Before we can use this framework to create a web application, let’s quickly get started with a skeleton setup of ColdBox.

1. Create Default Skeleton Codebase

  • Go to http://www.coldbox.org/download and download the ColdBox Bundle. The ColdBox Bundle includes the core framework plus: application templates, API Docs, IDE Extras, and more.
  • Unzipped the ColdBox Bundle, and copy the coldbox folder to your webroot. If inetpub/wwwroot is your webroot, then you should now have a folder called coldbox under there.
  • Select one of the ColdBox templates from the ApplicationTemplates folder in the unzipped ColdBox Bundle. You can choose from the following templates:
    • Advanced (if you like to use CF tags)
    • AdvancedScript (if you like to use CFScript)
    • REST
    • Simple
    • SuperSimple
  • Rename this template folder to your application name, and place it under your webroot in a location of your choice, e.g. inetpub/wwwroot/apps/myColdBoxApp
  • Browse the main page to confirm that ColdBox loads (e.g. inetpub/wwwroot/apps/myColdBoxApp/index.cfm). You should see something similar to this page loading (although your version number maybe different to mine):coldbox-main-no-security

2. Install Solitary Security Module for ColdBox

  • Create a new blank database on the database server that will hold the data for this application, including the users and roles for the security module we are about to install
  • Assign db_dataread, db_datawrite, and db_ddladmin database roles for the Windows user that will access this new database
  • Log into ColdFusion Admin and create a new data source for this new database
  • Download the Solitary security module for ColdBox from here: http://www.coldbox.org/forgebox/view/Solitary
  • Drop the solitary folder into your modules folder, i.e. myColdBoxApp/modules/
  • Add a mapping to myColdBoxApp/Application.cfc just after this line COLDBOX_APP_KEY
    this.mappings[‘/solitary’] = COLDBOX_APP_ROOT_PATH & “/modules/solitary”;
  • Update myColdBoxApp/Application.cfc to enable ORM
    this.ormEnabled = true;

    this.datasource = “YOUR_DATASOURCE_HERE”;
    this.ormSettings = {
    dbcreate = “update”,
    eventhandling = true,
    flushAtRequestEnd = false,
    cfclocation = []
    };
  • Ensure the following is present in the onRequest function in Application.cfc:
    if( structKeyExists(URL,”ORMReload”) ){
    ORMReload();
    }
  • Save Application.cfc
  • Edit modules/solitary/config/setup.xml and ensure there is at least an admin user and role (add or remove the other as required)
  • Browse the main page and ensure you do the following to update the application in the given order:
    index.cfm?ormReload
    index.cfm?fwreinit
  • The first update, ormReload, will update the model by creating the users, roles, users_roles and any other tables in your application’s model if they don’t exist, or update them if they do.
  • The second update, fwreinit, will re-initialise the ColdBox application
  • You should now be presented with a logon prompt for the ColdBox application

initial-logon-prompt

3. Customising your application

Here are some files and their locations which may come in handy for you to customise your application:

/config/ColdBox.cfc: Your application configuration file
/config/routes.cfm: Your URL Mappings
/handlers: Your application event handlers
/includes: Assets, Helpers, i18n, templates and more.
/layouts:Your application skin layouts
/model: Your model layer
/modules: Your application modules
/plugins: Where you place ColdBox custom plugins built by you!
/test: Your unit testing harness (Just DO IT!!)
/views: Your application views

You’re now ready to dig into codes to create your application using the ColdBox framework! Enjoy!

The above steps was carried out in the following environment:

  • MS Windows Server 2008
  • MS SQL Server 2008 R2
  • Adobe ColdFusion 10 Enterprise

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s