My First ColdBox Application
CommandBox comes with a coldbox create app command that can enable you to create application skeletons using one of our official skeletons or your own. Here are the names of the common ones you can find in our Github Organization:
  • AdvancedScript (default): A script based advanced template
  • elixir : A ColdBox Elixir based template
  • ElixirBower : A ColdBox Elixir + Bower based template
  • ElixirVueJS : A ColdBox Elixir + Vue.js based template
  • rest: A RESTFul services template
  • rest-hmvc: A RESTFul service built with modules
  • Simple : A traditional simple template
  • SuperSimple : The bare-bones template
You can find all our template skeletons here: github.com/coldbox-templates
Introduction
ColdBox Elixir
ColdBox Elixir Docs

Scaffolding Our Application

So let's create our first app using the default template skeleton AdvancedScript:
1
coldbox create app Quickstart
Copied!
This will scaffold the application and also install ColdBox for you. The following folders/files are generated for you:
1
+ coldbox // The ColdBox framework library (CommandBox Tracked)
2
+ config // Configuration files
3
+ handlers // Your handlers/controllers
4
+ includes // static assets
5
+ interceptors // global interceptors
6
+ layouts // Your layouts
7
+ lib // Java Jars to load
8
+ models // Your Models
9
+ modules // CommandBox Tracked Modules
10
+ modules_app // Custom modules
11
+ tests // Test harness
12
+ views // Your Views
13
+ Application.cfc // Bootstrap
14
+ box.json // CommandBox package descriptor
15
+ index.cfm // Front controller
Copied!
Now let's start a server so we can see our application running:
1
server start
Copied!
This will start up a Lucee 5 open source CFML engine. If you would like an Adobe ColdFusion server then just add to the command: [email protected]{version} where {version} can be: 2021,2018,2016.

Default Event

This command will start a server with URL rewrites enabled, open a web browser for you and execute the index.cfm which in turn executes the default event by convention in a ColdBox application: main.index. This is now our first convention!
Instead of executing pages like in a traditional application, we always execute the same page but distinguish the event we want via URL routing. When no mappings are present we execute the default event by convention.
Tip: ColdBox Events map to handlers (cfc) and appropriate actions (functions)
Tip: The default event can be also changed in the configuration file: config/Coldbox.cfc
Hooray, we have scaffolded our first application, started a server and executed the default event. Explore the application template generated, as it contains many useful information about your application.
Tip: Type coldbox create app help to get help on all the options for creating ColdBox applications.

File/Folder Conventions

ColdBox is a conventions based framework, meaning you don't have to explicitly write everything. We have a few contracts in place that you must follow and boom,
🎉
things happen. The location and names of files and functions matter. Since we scaffolded our first application, let's write down in a table below with the different conventions that exist in ColdBox.
File/Folder Convention
Mandatory
Description
config/Coldbox.cfc
false
The application configuration file
config/Router.cfc
false
The application URL router
handlers
false
Event Handlers (controllers)
layouts
false
Layouts
models
false
Model layer business objects
modules
false
CommandBox Tracked Modules
modules_app
false
Custom Modules You Write
tests
false
A test harness with runners, specs and more.
views
false
Views
What is the common denominator in all the conventions? That they are all optional.
Nothing is really mandatory in ColdBox anymore.

Re-initializing The Application

There will be times when you make configuration or code changes that are not reflected immediately in the application due to caching. You can tell the framework to reinit or restart the application for you via the URL by leveraging the special URL variable fwreinit.
1
http://localhost:{port}/?fwreinit=1
Copied!
You can also use CommandBox to reinit the application:
1
coldbox reinit
Copied!
Tip: You can add a password to the reinit procedures for further security, please see the configuration section.