Skip to content

Command Line Tools

Quick Start Guide

Get up and running with Wheels CLI in minutes.

  • CommandBox 5.0+
  • Java 8+
  • Database (MySQL, PostgreSQL, SQL Server, or H2)
Terminal window
# macOS/Linux
curl -fsSl https://downloads.ortussolutions.com/debs/gpg | sudo apt-key add -
echo "deb https://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a /etc/apt/sources.list.d/commandbox.list
sudo apt-get update && sudo apt-get install commandbox
# Windows (PowerShell as Admin)
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install commandbox
Terminal window
box install wheels-cli
Terminal window
wheels new blog
cd blog

This creates a new Wheels application with:

  • Complete directory structure
  • Configuration files
  • Sample code

Edit /config/settings.cfm:

<cfset set(dataSourceName="blog_development")>

Or use H2 embedded database:

Terminal window
wheels new blog --setupH2

Create the database:

Terminal window
# If using external database (MySQL, PostgreSQL, etc.)
wheels db create
Terminal window
box server start

Visit http://localhost:3000

Let’s create a blog post feature:

Terminal window
wheels generate scaffold name=post properties=title:string,content:text,published:boolean

This generates:

  • Model with validations
  • Controller with CRUD actions
  • Views for all actions
  • Database migration
  • Test files
Terminal window
wheels dbmigrate latest

Edit /config/routes.cfm:

<cfscript>
// Add this line
resources("posts");
</cfscript>
Terminal window
wheels reload

Visit http://localhost:3000/posts

You now have a fully functional blog post management system!

Terminal window
# Run all tests
wheels test run
# Watch mode
wheels test run --watch
# Specific tests
wheels test run tests/models/PostTest.cfc

Let’s add comments to posts:

Terminal window
# Generate comment model
wheels generate model comment --properties="author:string,content:text,postId:integer" \
--belongsTo="post"
# Update post model
wheels generate property post comments --has-many
# Generate comments controller
wheels generate controller comments --rest
# Run migration
wheels dbmigrate latest
Terminal window
# Generate user model
wheels scaffold name=user properties=email:string,password:string,admin:boolean
# Generate session controller
wheels generate controller sessions new,create,delete
# Run migrations
wheels dbmigrate latest
Terminal window
# Generate API resource
wheels generate api-resource product --properties="name:string,price:decimal"
# Or convert existing to API
wheels generate controller api/posts --api
Terminal window
# Generate specific views
wheels generate view posts featured
wheels generate view users profile
# Add layouts
echo '<cfoutput><!DOCTYPE html>...</cfoutput>' > views/layout.cfm

Always use migrations for database changes:

Terminal window
# Create tables
wheels dbmigrate create table products
# Add columns
wheels dbmigrate create column products featured
# Create indexes
wheels dbmigrate create blank add_index_to_products

Generate tests for your code:

Terminal window
# After creating a model
wheels generate test model post
# After creating a controller
wheels generate test controller posts
Terminal window
# Development
wheels reload development
# Testing
wheels reload testing
# Production
wheels reload production
Terminal window
git init
git add .
git commit -m "Initial Wheels application"

Add to .gitignore:

/db/sql/
/logs/
/temp/
.env
Terminal window
tail -f logs/wheels.log

In /config/settings.cfm:

<cfset set(showDebugInformation=true)>

Port already in use:

Terminal window
box server start port=3001

Database connection failed:

Terminal window
# Check datasource
box server info
box server show

Migration failed:

Terminal window
# Check status
wheels db status
# Run specific migration
wheels dbmigrate exec 20240120000000
# Or rollback and try again
wheels db rollback

Need to reset database:

Terminal window
# Complete reset (careful - destroys all data!)
wheels db reset --force

Access database directly:

Terminal window
# CLI shell
wheels db shell
# Web console (H2 only)
wheels db shell --web
  1. Read the Guides:

  2. Explore Commands:

    • wheels --help
    • wheels generate --help
    • wheels dbmigrate --help
  3. Join the Community:

Here’s a complete blog setup:

Terminal window
# Create application
wheels new myblog --setupH2
cd myblog
# Generate blog structure
wheels scaffold post title:string,slug:string,content:text,publishedAt:datetime
wheels scaffold author name:string,email:string,bio:text
wheels generate model comment author:string,email:string,content:text,postId:integer \
--belongsTo=post
# Update associations
wheels generate property post authorId:integer --belongsTo=author
wheels generate property post comments --has-many
wheels generate property author posts --has-many
# Add routes
echo '<cfset resources("posts")>' >> config/routes.cfm
echo '<cfset resources("authors")>' >> config/routes.cfm
# Setup and seed database
wheels db setup --seed-count=10
# Start development
wheels server start
# Visit http://localhost:3000/posts

You now have a working blog with posts, authors, and comments!