[ColdBox-4.1.0] Mapping to module's model objects in Wirebox

At the moment I can map to a model object in my module by doing this:


Is it possible to shorten it to:


I tried setting in ModuleConfig.cfc
this.cfmapping = "myModule";

but didn’t work.

Hi Nick,

You can map models of module like this


following information for module config

Module Directives as public properties
this.title = “Title of the module”;
this.author = “Author of the module”;
this.webURL = “Web URL for docs purposes”;
this.description = “Module description”;
this.version = “Module Version”;
this.viewParentLookup = (true) [boolean] (Optional) // If true, checks for views in the parent first, then it the module.If false, then modules first, then parent.
this.layoutParentLookup = (true) [boolean] (Optional) // If true, checks for layouts in the parent first, then it the module.If false, then modules first, then parent.
this.entryPoint = “” (Optional) // If set, this is the default event (ex:forgebox:manager.index) or default route (/forgebox) the framework
will use to create an entry link to the module. Similar to a default event.
// Execution Aliases
this.aliases = [];
// Auto Map Models Directory
this.autoMapModels = true;
// Model Namespace
this.modelNamespace = “”;
// CF Mapping
this.cfmapping = “”;
// Module Dependencies
this.dependencies = [];

structures to create for configuration

  • parentSettings : struct (will append and override parent)
  • settings : struct
  • datasources : struct (will append and override parent)
  • interceptorSettings : struct of the following keys ATM
  • customInterceptionPoints : string list of custom interception points
  • interceptors : array
  • layoutSettings : struct (will allow to define a defaultLayout for the module)
  • routes : array Allowed keys are same as the addRoute() method of the SES interceptor.
  • wirebox : The wirebox DSL to load and use

Available objects in variable scope

  • controller
  • appMapping (application mapping)
  • moduleMapping (include,cf path)
  • modulePath (absolute path)
  • log (A pre-configured logBox logger object for this object)
  • binder (The wirebox configuration binder)
  • wirebox (The wirebox injector)

Configuration Method

  • configure() : The method ColdBox calls to configure the module upon framework initialization

Life Cycle Methods

  • onLoad() : If found, it is fired once the module is fully loaded
  • onUnload() : If found, it is fired once the module is unloaded


What Sana suggested is the proper way to get the full path. This is very important since you can’t control where the module might be installed to (it might not even be in the web root).

However, what is much better is simply to add the singleton annotation to your CFC and then there is no need to map it at all! ColdBox will automatically map all models recursively in your models folder as long as autoMapModels is enabled in your ModuleConfig.cfc (default for ColdBox 4.+)

component singletion {



Thanks Sana and Brad, will give both approach a go.