# macOS/Linuxcurl-fsSlhttps://downloads.ortussolutions.com/debs/gpg|sudoapt-keyadd-echo"deb https://downloads.ortussolutions.com/debs/noarch /"|sudotee-a/etc/apt/sources.list.d/commandbox.listsudoapt-getupdate&&sudoapt-getinstallcommandbox# Windows (PowerShell as Admin)iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))chocoinstallcommandbox
Install Wheels CLI
box install wheels-cli
Creating Your First Application
1. Generate Application
wheels new blog
cd blog
This creates a new Wheels application with:
Complete directory structure
Configuration files
Sample code
2. Configure Database
Edit /config/settings.cfm:
<cfset set(dataSourceName="blog_development")>
Or use H2 embedded database:
wheels new blog --setupH2
Create the database:
# If using external database (MySQL, PostgreSQL, etc.)
wheels db create
<cfscript>
// Add this line
resources("posts");
</cfscript>
4. Reload Application
wheels reload
5. Test Your Feature
Visit http://localhost:3000/posts
You now have a fully functional blog post management system!
Development Workflow
File Watching
In a new terminal:
wheels watch
Now changes to .cfc and .cfm files trigger automatic reloads.
Running Tests
# Run all tests
wheels test run
# Watch mode
wheels test run --watch
# Specific tests
wheels test run tests/models/PostTest.cfc
Adding Relationships
Let's add comments to posts:
# Generate comment model
wheels generate model comment --properties="author:string,content:text,postId:integer" \
--belongs-to="post"
# Update post model
wheels generate property post comments --has-many
# Generate comments controller
wheels generate controller comments --rest
# Run migration
wheels dbmigrate latest
Common Tasks
Adding Authentication
# 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
Adding API Endpoints
# Generate API resource
wheels generate api-resource product --properties="name:string,price:decimal"
# Or convert existing to API
wheels generate controller api/posts --api