Alrighty, I'm finally getting around to looking at ColdBox. So the first thing I did was
download the framework. I'm currently working with the latest (2.03) version.
Next, i extracted the zip file to a coldbox folder in my webroot. Finally, I created a mapping in CF Administrator for "/coldbox". These frameworks seem to all install pretty much the same. As my last install step. I went to http://localhost/coldbox/samples. Yep, everything's working great.
Now to finally creating my first application. I pretty much followed the tutorials and docs that Luis provides. There is a wealth of documentation available.
Let's get cracking now. First I copied the "ApplicationTemplate" directory from the coldbox install folder to my labs folder and renamed it helloCB.
To make sure everything worked, i pointed my browser to http://localhost/labs/helloCB. Success! I see a page telling me my ColdBox version and other debugging information.
I noticed in the debugging information that my Application name is "Your App Name Here". I decided I should change that. To do so I simply opened up the application configuration file which lives at config/colbox.xml.cfm. I decided to change the AppName attribute to "Hello CB".
The tutorial mentions an number of other important settings, and they're all well documented within the file itself.
Here are a few settings that are mentioned.
- AppName : The name of your application.
- DebugMode : To show or not the debugging panel (set to true)
- DebugPassword : Set to blank for dev use (please remember to fill one up)
- EnableColdboxLogging : Enables AOP logging for exceptions and information messages. (set to true)
- ColdboxLogsLocation : Default location of the log files logs within your application
- DefaultEvent : The event to fire when application starts up or there are is no event defined. (set to ehGeneral.dspHello)
- RequestStartHandler' : The event to fire at the beginning of every request. (set to ehMain.onRequestStart)
- RequestEndHandler : The event to fire at the end of every request. (set to ehMain.onRequestEnd)
- ApplicationStartHandler : The event to fire when application starts up. (set to ehMain.onAppInit)
- ConfigAutoReload : To reload the configuration file and reinit the app(set to true, development only)
- HandlerCaching : To cache the event handler cfc's in the ColdBox cache. (set to false) You do not want to enable this in development unless you are doing load tests. If not, you won't see changes reflected until you refresh the cache.
- DefaultLayout : The default layout to use for rendering views.
To finish off our first application, let's add our "Hello World" message. Looking at the config file we see that our DefaultEvent is general.dspHome. Let's look at the event handler. Looking in the handlers folder we see a CFC named "general". This CFC handles the "general.dspHome" event. Opening up the CFC we see that it has a couple methods. The first method, "dspHome" is the one we want. Notice the line
<cfset Event.setValue("welcomeMessage","Welcome to ColdBox!")>
Let's change "Welcome to ColdBox!" to "Hello World!". If we reload our application we should see our new message displayed.
Pretty cool stuff. Next time we'll get a little meatier, but that was a nice easy start.