Skip to content

Command Line Tools

wheels generate - commands

These are the commands in the wheels generate namespace. These commands are called by some of the top level commands but you can use them directly to speed up your development process.

The wheels generate command is what CommandBox calls a namespace and contains many sub commands beneath it. It’s main purpose is to isolate those sub commands so there is no name collisions. It also has an alias of wheels g which allows you to shorten the commands you have to type. However, we have opted to show all the commands with their full names in the list below.

Creates a new CFWheels application using our wizard to gather all the necessary information. This is the recommended route to start a new application.

This command will ask for:

  • An Application Name (a new directory will be created with this name)
  • Template to use
  • A reload Password
  • A datasource name
  • What local cfengine you want to run
  • If using Lucee, do you want to setup a local h2 dev database
  • Do you want to initialize the app as a ForgeBox module
wheels new
wheels g app-wizard
wheels generate app-wizard

All these three commands are equivalent and will call the same wizard. The wizard in turn gathers all the required data and passes it all off to the wheels generate app command to do all the heavy lifting.

Let’s take a look at the wizard pages after issuing the wheels new command:

wheels new - step 1

You can accept the name offered or change it to whatever name you like. We try to clean up the name and take out special characters and spaces if we need to.

wheels new - step 2

You can select a template to use. If you are reading this before CFWheels 2.4 is released you may want to select the Bleeding Edge Base Template.

wheels new - step 3

You can set what you want to use as your reload password or accept the default. Please make sure to change this before you go into production. Ideally this should be kept out of your source repository by using something like the (CFWheels DotEnvSettings Plugin)[https://www.forgebox.io/view/cfwheels-dotenvsettings].

wheels new - step 4

The datasource is something you’ll have to take care of unless you opt to use the H2 Embedded database in a Lucee server. Here you can define the datasource name if you would like to use something different than the application name.

wheels new - step 5

In this step you can choose what CF Engine and version to launch. Lucee has an embedded SQL compliant database server called H2. So if you use one of the Lucee options you can specify to use the H2 database as well. Notice the last item allows you to specify the module slug or URI to a CF Engine not on the list.

wheels new - step 6

On this step you are asked if you’d like to use the H2 Database, in which case we can set everything up for you, or if you would prefer to use another database engine and will take care of setting up the database yourself.

wheels new - step 7

On this last step, you are asked if you want us to include a box.json file so you can eventually submit this to ForgeBox.io for sharing with he world.

wheels new - step 8

This is the confirmation screen that shows all the choices you’ve made and gives you one last chance to bail out. If you choose to continue, the choices you’ve made will be sent over to the wheels g app command to do the actual app creation.

wheels new - final screen

If you opted to continue you’ll see a bunch of things scroll across your screen as the various items are downloaded and configured. Eventually you will see this status screen letting you know that everything was installed properly.

Create a blank CFWheels app from one of our app templates or a template using a valid Endpoint ID which can come from ForgeBox, HTTP/S, git, github, etc.

By default an app named MyCFWheelsApp will be created in a sub directory called MyCFWheelsApp.

The most basic call…

wheels generate app

This can be shortened to…

wheels g app

Here are the basic templates that are available for you that come from ForgeBox

  • CFWheels Base Template - Stable (default)
  • CFWheels Base Template - Bleeding Edge
  • CFWheels Template - HelloWorld
  • CFWheels Template - HelloDynamic
  • CFWheels Template - HelloPages
  • CFWheels Example App
  • CFWheels - TodoMVC - HTMX - Demo App
wheels create app template=base

The template parameter can also be any valid Endpoint ID, which includes a Git repo or HTTP URL pointing to a package. So you can use this to publish your own templates to use to start new projects.

wheels create app template=http://site.com/myCustomAppTemplate.zip
ParameterRequiredDefaultDescription
namefalseMyCFWheelsAppThe name of the app you want to create
templatefalsebase templateThe name of the app template to use
directoryfalsemycfwheelsapp/The directory to create the app in
reloadPasswordfalseChangeMeThe reload password to set for the app
datasourceNamefalseMyCFWheelsAppThe datasource name to set for the app
cfmlEnginefalseLuceeThe CFML engine to use for the app
setupH2falsefalseSetup the H2 database for development
initfalsefalse”init” the directory as a package if it isn’t already
forcefalsefalseForce installation into an none empty directory

Adds a default resources Route to the routes table. All the normal CRUD routes are automatically added.

wheels generate route [objectname]
ParameterRequiredDefaultDescription
objectnametrueThe name of the resource to add to the routes table

I generate a controller in the controllers/ directory. You can either pass in a list of actions to stub out or the standard CRUD methods will be generated.

Create a user controller with full CRUD methods

wheels generate controller user

Create a user object with just “index” and “customaction” methods

wheels generate controller user index,customaction
ParameterRequiredDefaultDescription
nametrueName of the controller to create without the .cfc
actionListfalseoptional list of actions, comma delimited
directoryfalseif for some reason you don’t have your controllers in controllers/

This command generates a model in the models/ folder and creates the associated DB Table using migrations.

Create “users” table and “User.cfc” in models:

wheels generate model user

Create just “User.cfc” in models:

wheels generate model user false
ParameterRequiredDefaultDescription
nametrueName of the model to create without the .cfc: assumes singular
dbfalseBoolean attribute specifying if the database table should be generated as well

This command generates a dbmigration file to add a property to an object and scaffold into _form.cfm and show.cfm if they exist (i.e, wheels generate property table columnName columnType).

Create the a string/textField property called firstname on the User model:

wheels generate property user firstname

Create a boolean/Checkbox property called isActive on the User model with a default of 0:

wheels generate property user isActive boolean

Create a boolean/Checkbox property called hasActivated on the User model with a default of 1 (i.e, true):

wheels generate property user isActive boolean 1

Create a datetime/datetimepicker property called lastloggedin on the User model:

wheels generate property user lastloggedin datetime

All columnType options: biginteger,binary,boolean,date,datetime,decimal,float,integer,string,limit,text,time,timestamp,uuid

ParameterRequiredDefaultDescription
nametrueTable Name
columnNamefalseName of Column
columnTypefalseType of Column on of biginteger, binary, boolean, date, datetime, decimal, float,integer, string, limit, text, time, timestamp, uuid
defaultfalseDefault Value for column
nullfalseWhether to allow null values
limitfalsecharacter or integer size limit for column
precisionfalseprecision value for decimal columns, i.e. number of digits the column can hold
scalefalsescale value for decimal columns, i.e. number of digits that can be placed to the right of the decimal point (must be less than or equal to precision)

This command generates a view file in the views/ directory when specifying the object name and the action. If a directory for the object does not exist a subdirectory will be created in the views/ directory and the action NAME.cfm file place into it.

Create a default file called show.cfm without a template

wheels generate view user show

Create a default file called show.cfm using the default CRUD template

wheels generate view user show crud/show
ParameterRequiredDefaultDescription
objectnametrueView path folder, i.e user
nametrueName of the file to create, i.e, edit
templatefalsetemplate (used in Scaffolding) - options crud/_form,crud/edit,crud/index,crud/new,crud/show

This command generates a test stub in /test/TYPE/NAME.cfc.

wheels generate test model user
wheels generate test controller users
wheels generate test view users edit
ParameterRequiredDefaultDescription
typetrueType of test to generate. Options are model, controller, and view
objectnametrueView path folder or name of object, i.e user
nametrueName of the action/view