ColdBox Output Example

On this page

ColdBox Output Example

A real example of what bxSites coldbox produces. Everything below came out of an actual run against the small Bookshelf application sketched here - nothing is hand-written illustration.

The application declares a router, one handler, one model, a WireBox binder, a scheduler, an interceptor, and an api module with a router and handler of its own:

class {
	function configure() {
		route( "/" ).as( "home" ).to( "books.index" )
		route( "/books/:id" ).to( "books.show" )
		resources( "books" )
		route( "/old/shelf" ).toRedirect( "/books" )
		route( ":handler/:action?" ).end()
	}
}
/**
 * The public bookshelf endpoints.
 */
class {

	/**
	 * List every book on the shelf.
	 *
	 * @event The request context
	 *
	 * @return the rendered listing
	 */
	function index( event, rc, prc ) {}

	/**
	 * Show one book by id.
	 *
	 * @id The book id
	 */
	function show( event, rc, prc ) {}

	/**
	 * Runs before every action in this handler.
	 */
	function preHandler( event, rc, prc, action, eventArguments ) {}

	private function findOr404( id ) {}
}
class {
	this.title = "Bookshelf API"
	this.author = "Ortus Solutions"
	this.version = "1.0.0"
	this.entryPoint = "api"
	this.dependencies = [ "cbsecurity" ]
}

One bxSites coldbox run over that writes eleven pages. Five of them are reproduced below, rendered for real rather than as code blocks.

The generated pages cross-link each other; in these excerpts those references are shown as plain code, since their targets only exist inside a generated site.


routes.md

Routes

16 route(s), in the order the routers declare them - ColdBox matches the first one that fits, so order is meaningful.

VerbsPatternTargetNameModule
ANY/books.indexhomeโ€”
ANY/books/:idbooks.showโ€”โ€”
GET/booksbooks.indexโ€”โ€”
GET/books/newbooks.newโ€”โ€”
POST/booksbooks.createโ€”โ€”
GET/books/:idbooks.showโ€”โ€”
GET/books/:id/editbooks.editโ€”โ€”
PUT/PATCH/books/:idbooks.updateโ€”โ€”
DELETE/books/:idbooks.deleteโ€”โ€”
ANY/old/shelf/books redirectโ€”โ€”
ANY:handler/:action?by conventionโ€”โ€”
GET/api/booksbooks.indexโ€”api
POST/api/booksbooks.createโ€”api
GET/api/books/:idbooks.showโ€”api
PUT/PATCH/api/books/:idbooks.updateโ€”api
DELETE/api/books/:idbooks.deleteโ€”api

A route marked by convention has no explicit target: ColdBox resolves the handler and action from the URL pattern's own placeholders.


Worth noticing in that table: resources( "books" ) expanded into the seven routes ColdBox generates for it, the module's apiResources() expanded into five more and carried the /api entry point its ModuleConfig declares, and the conventions route kept its literal pattern.


handlers/Books.md

Books

handlers.Books

The public bookshelf endpoints.

Routes

VerbsPatternAction
ANY/index
ANY/books/:idshow
GET/booksindex
GET/books/newnew
POST/bookscreate
GET/books/:idshow
GET/books/:id/editedit
PUT/PATCH/books/:idupdate
DELETE/books/:iddelete

Actions

Any index( event, rc, prc )

List every book on the shelf.

Reached by /, /books

ParameterTypeRequiredDescription
eventAnynoThe request context
rcAnyno
prcAnyno
  • Returns the rendered listing

Any show( event, rc, prc )

Show one book by id.

Reached by /books/:id, /books/:id

ParameterTypeRequiredDescription
eventAnyno
rcAnyno
prcAnyno

Lifecycle hooks

ColdBox calls these itself around the handler's actions - they aren't reachable as events of their own.

Any preHandler( event, rc, prc, action, eventArguments )

Runs before every action in this handler.

ParameterTypeRequiredDescription
eventAnyno
rcAnyno
prcAnyno
actionAnyno
eventArgumentsAnyno

The Routes section is built by matching route targets back to the handler, so a reader landing on a handler page immediately sees how it is reached and which action each URL hits. preHandler is separated out as the lifecycle hook it is, and the private findOr404 never appears.


models/index.md

Models

ModelModuleScopeInjects
Bookโ€”singleton1

WireBox mappings

Declared in the application's binder. A model with no mapping here is still injectable - WireBox maps the models directory by convention.

AliasMaps toKindScopeModule
BookServicemodels.BookServiceclasssingletonโ€”
models.servicesmodels.servicesdirectoryโ€”โ€”

modules/api.md

Bookshelf API

api ยท mounted at /api

AuthorOrtus Solutions
Version1.0.0
Entry pointapi
Depends oncbsecurity

Routes

VerbsPatternTarget
GET/api/booksbooks.index
POST/api/booksbooks.create
GET/api/books/:idbooks.show
PUT/PATCH/api/books/:idbooks.update
DELETE/api/books/:idbooks.delete

Handlers

  • Books

scheduled-tasks.md

Scheduled tasks

TaskScheduleRunsConstraintsModule
Reindex the shelfevery day at 02:00runEvent( "books.reindex" )one server onlyโ€”

A scheduled task's work is a closure, not a literal, so there is nothing to resolve statically. Rather than leave the most useful column empty, the closure's own source text is carried through as written - which is exactly what the scheduler will run.

See ColdBox Applications for configuration and for what static reading deliberately cannot see, and DocBox Output Example for the API reference the same project's classes produce.

Edit this page Download Markdown Last updated Sep 11, 2026, 7:11:15 PM