My First ColdBox Application
Default: The default app template
Rest: A RESTFul services template
Rest-hmvc: A RESTFul service built with modules
SuperSimple : The bare-bones template
Vite: The default template using VITE for asset bundling
Scaffolding Our Application
So let's create our first app using the default template skeleton:
File/Folder Conventions
Here are some of the major files and directory conventions you should know about:
Here are the major files you should know about:
Now let's start a server so we can see our application running:
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 runtime convention!
Tip: ColdBox Events map to handlers (cfc) and appropriate actions (functions)
Tip: The default event can also be 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, which contains useful information about your application.
Tip: Type coldbox create app help
to get help on all the options for creating ColdBox applications.
Let's open the handler and see the code, so open handlers/main.cfc
The action (function) we are interested in is the index()
function.
It sets a message in an incoming prc
argument and then calls a method in the incoming event
argument to set a view for rendering. We will discover these arguments in the next section. For now, we need to understand that handler actions are in place of traditional CFML pages. Depending on the incoming URL route, we execute the appropriate handler and action function.
Re-initializing the Application
There will be times when you make configuration or metadata/singleton 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
.
You can also use CommandBox to reinit the application:
Last updated