Blog

Gavin Pickin

June 01, 2016

Spread the word


Share your thoughts

In previous posts we have talked about creating a ColdBox module from scratch ( ContentBox - Extending ContentBox 3 with your Own Custom Modules ), one file at a time, to see the minimum files required to make the module work. That was a great educational exercise, but lets look at another way to create a module, with CommandBox's ColdBox scaffholding commands. 


The Coldbox command inside of CommandBox  allows you to do a lot of things, including coldbox create for all of these items:

  • view
  • app-wizard
  • orm-virtual-service
  • unit
  • integration-test
  • interceptor-test
  • orm-entity
  • orm-service
  • app
  • interceptor
  • orm-event-handler
  • model
  • layout
  • handler
  • bdd
  • module
  • orm-crud
  • model-test
  • controller

We are of course interested in creating a module. Lets look at that command

#coldbox create module

The params for this command are the following:

  • name=            
  • author=          
  • authorURL=       
  • description=     
  • version=
  • modelNamespace=  
  • dependencies=    
  • directory=       
  • script=          

There is also a flag for script: --script

Lets create a module with the command, and see what it produces.
Note: Be in the root of your app so the command knows where to put the files. If you are in a subfolder, the command might get lost. 

coldbox create module name=customModule2 author="Gavin Pickin" authorURL="http://www.gpickin.com" description="Custom Module 2" version="1.2.3" cfmapping="customModule2Mapping" modelNamespace="customModuleName" directory="modules_app" script=true

 

Looking at the arguments in more detail

  • name=customModule2
  • author="Gavin Pickin"
  • authorURL="http://www.gpickin.com"
  • description="Custom Module 2"
  • version="1.2.3"
  • cfmapping="customModule2Mapping"
  • modelNamespace="customModuleName"
  • directory="modules_app"
  • script=true

The command outputs this:

Created C:\www\wwwplayground\modules_app/customModule2
Created C:\www\wwwplayground\modules_app\customModule2\handlers
Created C:\www\wwwplayground\modules_app\customModule2\handlers\Home.cfc
Created C:\www\wwwplayground\modules_app\customModule2\models
Created C:\www\wwwplayground\modules_app\customModule2\models\models_here.txt
Created C:\www\wwwplayground\modules_app\customModule2\ModuleConfig.cfc
Created C:\www\wwwplayground\modules_app\customModule2\views
Created C:\www\wwwplayground\modules_app\customModule2\views\home
Created C:\www\wwwplayground\modules_app\customModule2\views\home\index.cfm


Here is a visual display of the directory structure


You can see it creates a Module Config file with all your information ( click here to view the GIST ).
It creates a default handler, called Home.cfc in the handlers folder.
It creates a models folder, with just a placeholder file.
It creates a views folder, with the 'home' folder to match the handler, and creates a default index.cfm view.

It is a great way to get started. You can use many of the other coldbox commands to create additional handlers, views, layouts.
So next time you want to create a module, instead of remembering the conventions, and what files you need... just scaffold it with commandbox's coldbox create command.

Remember, these modules all work great with ContentBox, so what will you create?
 

Recent Entries

Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024
Ortus February Newsletter 2024

Ortus February Newsletter 2024

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
March 06, 2024
Unveiling the Future of CFML Development - 3rd Round of Sessions

Unveiling the Future of CFML Development - 3rd Round of Sessions

Welcome back to our journey into the future of CFML development! As excitement continues to build for Into the Box 2024, we're thrilled to bring you the latest updates on what promises to be a transformative event. Continuing our blog post series, let's delve deeper into the third wave of session releases and discover the key surprises awaiting attendees. Learn More

Maria Jose Herrera
Maria Jose Herrera
March 01, 2024