Skip to content

Command Line Tools

wheels env setup

Setup a new environment configuration for your Wheels application with comprehensive database, template, and configuration options.

Terminal window
wheels env setup environment=<name> [options]

The wheels env setup command creates and configures new environments for your Wheels application. It generates:

  • Environment-specific .env.[environment] files with database and server settings using generic DB_* variable names
  • Configuration files at config/[environment]/settings.cfm with Wheels settings
  • Template-specific files (Docker, Vagrant) if requested
  • Server.json updates for environment-specific configurations
  • Updates config/environment.cfm with the current environment setting

The command supports copying configurations from existing environments and allows full customization of database types, templates, and framework settings.

When setting up environments with server-based databases (MySQL, PostgreSQL, MSSQL, Oracle), if database credentials are not provided as command arguments, the command will interactively prompt you to enter:

  • Database host (default: localhost)
  • Database port (database-specific defaults)
  • Database username (default: varies by database type)
  • Database password (masked input)
  • Oracle SID (Oracle only)

This ensures you never use incorrect default credentials that could cause authentication failures.

ArgumentDescriptionRequired
environmentEnvironment name (e.g., development, staging, production, testing)Yes

Note: Always use named parameter syntax: environment=name to avoid parameter conflicts.

OptionDescriptionDefaultValid Values
--templateDeployment template typelocallocal, docker, vagrant
--dbtypeDatabase typeh2h2, sqlite, mysql, postgres, mssql, oracle
--databaseCustom database namewheels_[environment]Any valid database name
--datasourceColdFusion datasource namewheels_[environment]Any valid datasource name
--hostDatabase hostlocalhost (or prompted)Any valid hostname/IP
--portDatabase portDatabase-specific (or prompted)Valid port number
--usernameDatabase usernameDatabase-specific (or prompted)Any valid username
--passwordDatabase password(prompted if not provided)Any string
--sidOracle SID (Oracle only)ORCL (or prompted)Any valid SID
--baseBase environment to copy from(none)Any existing environment name
--forceOverwrite existing environmentfalsetrue, false
--debugEnable debug settingsfalsetrue, false
--cacheEnable cache settingsfalsetrue, false
--reloadPasswordCustom reload passwordwheels[environment]Any string
--skipDatabaseSkip database creationfalsetrue, false
--helpShow detailed help informationfalse-
Terminal window
# Create development environment with H2 database (default)
wheels env setup environment=development
# Create development environment with SQLite database (file-based, no server required)
wheels env setup environment=development --dbtype=sqlite --database=myapp_dev
# Create staging environment with MySQL (will prompt for credentials)
wheels env setup environment=staging --dbtype=mysql
# Create production environment with PostgreSQL and caching enabled
wheels env setup environment=production --dbtype=postgres --cache=true --debug=false
# Create environment with explicit credentials (no prompting)
wheels env setup environment=test --dbtype=mssql --host=localhost --port=1433 --username=sa --password=MyPassword123!
Terminal window
# Running without credentials prompts interactively
wheels env setup environment=production --dbtype=mssql
# Output:
# Setting up production environment...
#
# Database credentials not provided for mssql database
# Would you like to enter database credentials now? [y/n] y
#
# Please provide database connection details:
#
# Database Host [localhost]: localhost
# Database Port [1433]: 1433
# Database Username [sa]: sa
# Database Password: ************
#
# Database credentials captured successfully!
Terminal window
# Copy settings from development environment but use PostgreSQL
wheels env setup environment=testing --base=development --dbtype=postgres
# Create staging environment based on production settings
wheels env setup environment=staging --base=production --database=staging_db
# Create QA environment with custom settings
wheels env setup environment=qa --base=development --dbtype=mysql --debug=true --cache=false
Terminal window
# Setup with custom database and datasource names
wheels env setup environment=integration --dbtype=mysql --database=wheels_integration_db --datasource=integration_ds
# Setup with specific reload password and debugging
wheels env setup environment=dev --debug=true --reloadPassword=mypassword123 --force
# Docker environment setup
wheels env setup environment=docker-dev --template=docker --dbtype=postgres --database=wheels_docker
Terminal window
# Local development (default)
wheels env setup environment=dev --template=local --dbtype=h2
# Docker containerized environment
wheels env setup environment=docker-staging --template=docker --dbtype=mysql
# Vagrant VM environment
wheels env setup environment=vm-test --template=vagrant --dbtype=postgres

1. Environment Variables File (.env.[environment])

Section titled “1. Environment Variables File (.env.[environment])”

Note: All database types now use generic DB_* variable names for portability and consistency.

For H2 database:

Terminal window
## Wheels Environment: development
## Generated on: 2025-01-18 12:30:00
## Application Settings
WHEELS_ENV=development
WHEELS_RELOAD_PASSWORD=wheelsdevelopment
## Database Settings
DB_TYPE=h2
DB_HOST=
DB_PORT=
DB_DATABASE=./db/wheels_development
DB_USER=sa
DB_PASSWORD=
DB_DATASOURCE=wheels_development
## Server Settings
SERVER_PORT=8080
SERVER_CFENGINE=lucee5

For SQLite database:

Terminal window
## Wheels Environment: development
## Generated on: 2025-01-18 12:30:00
## Application Settings
WHEELS_ENV=development
WHEELS_RELOAD_PASSWORD=wheelsdevelopment
## Database Settings
DB_TYPE=sqlite
DB_HOST=
DB_PORT=
DB_DATABASE=./db/myapp_dev.db
DB_USER=
DB_PASSWORD=
DB_DATASOURCE=wheels_development
## Server Settings
SERVER_PORT=8080
SERVER_CFENGINE=lucee5

For MySQL database:

Terminal window
## Wheels Environment: production
## Generated on: 2025-01-18 12:30:00
## Application Settings
WHEELS_ENV=production
WHEELS_RELOAD_PASSWORD=wheelsproduction
## Database Settings
DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=wheels_production
DB_USER=wheels
DB_PASSWORD=wheels_password
DB_DATASOURCE=wheels_production
## Server Settings
SERVER_PORT=8080
SERVER_CFENGINE=lucee5

For Microsoft SQL Server:

Terminal window
## Wheels Environment: staging
## Generated on: 2025-01-18 12:30:00
## Application Settings
WHEELS_ENV=staging
WHEELS_RELOAD_PASSWORD=wheelsstaging
## Database Settings
DB_TYPE=mssql
DB_HOST=localhost
DB_PORT=1433
DB_DATABASE=wheels_staging
DB_USER=sa
DB_PASSWORD=MySecurePassword123!
DB_DATASOURCE=wheels_staging
## Server Settings
SERVER_PORT=8080
SERVER_CFENGINE=lucee5

2. Configuration File (config/[environment]/settings.cfm)

Section titled “2. Configuration File (config/[environment]/settings.cfm)”
<cfscript>
// Environment: production
// Generated: 2025-01-18 12:30:00
// Debug Mode: Disabled
// Cache Mode: Enabled
// Database settings
set(dataSourceName="wheels_production");
// Environment settings
set(environment="production");
// Debug settings - controlled by debug argument
set(showDebugInformation=false);
set(showErrorInformation=false);
// Caching settings - controlled by cache argument
set(cacheFileChecking=true);
set(cacheImages=true);
set(cacheModelInitialization=true);
set(cacheControllerInitialization=true);
set(cacheRoutes=true);
set(cacheActions=true);
set(cachePages=true);
set(cachePartials=true);
set(cacheQueries=true);
// Security
set(reloadPassword="wheelsproduction");
// URLs
set(urlRewriting="partial");
// Environment-specific settings
set(sendEmailOnError=true);
set(errorEmailAddress="dev-team@example.com");
</cfscript>

Creates:

  • docker-compose.[environment].yml
  • Dockerfile (if not exists)

Creates:

  • Vagrantfile.[environment]
  • vagrant/provision-[environment].sh
  • Use Case: Development, testing, quick prototyping
  • Connection: No network port required (embedded)
  • Database Path: ./db/[database_name]
  • Default Credentials: username=sa, password=(empty)
  • Creation: Database file created on first connection (lazy creation)
Terminal window
wheels env setup environment=dev --dbtype=h2 --database=my_dev_db
  • Use Case: Development, testing, prototyping, portable applications, embedded systems
  • Connection: No network port required (file-based, serverless)
  • Database Path: ./db/[database_name].db
  • Default Credentials: No username/password required (file-based authentication)
  • Creation: Database file created immediately (eager creation)
  • JDBC Driver: org.sqlite.JDBC (org.xerial.sqlite-jdbc v3.47.1.0) - included with Lucee/CommandBox
  • Auxiliary Files: Creates .db-wal, .db-shm, .db-journal during operation
  • Configuration: Uses absolute paths in datasource configuration
  • Advantages:
    • Zero configuration - no server setup required
    • Portable - single file database, easy to backup/move
    • Fast - ideal for local development and testing
    • Self-contained - all data in one file
    • Cross-platform - works on Windows, macOS, Linux
  • Limitations:
    • Single writer - not suitable for high-concurrency scenarios
    • File locking - can cause issues on network drives
    • Not recommended for production with multiple concurrent users
Terminal window
# Basic SQLite environment setup
wheels env setup environment=dev --dbtype=sqlite --database=myapp_dev
# SQLite with custom database name
wheels env setup environment=test --dbtype=sqlite --database=integration_tests
# SQLite for prototyping
wheels env setup environment=prototype --dbtype=sqlite --database=prototype_v1
  • Use Case: Production, staging environments
  • Default Port: 3306
  • Default Credentials: username=wheels, password=wheels_password
Terminal window
wheels env setup environment=prod --dbtype=mysql --database=wheels_production
  • Use Case: Production, complex applications
  • Default Port: 5432
  • Default Credentials: username=wheels, password=wheels_password
Terminal window
wheels env setup environment=staging --dbtype=postgres
  • Use Case: Enterprise environments
  • Default Port: 1433
  • Default Credentials: username=sa, password=Wheels_Pass123!
Terminal window
wheels env setup environment=enterprise --dbtype=mssql

When using --base, the command copies configuration from an existing environment:

  • Database host, username, and password
  • Server configuration (port, CF engine)
  • Custom environment variables
  • Environment name
  • Database name (becomes wheels_[new_environment])
  • Database type, driver, and port (based on --dbtype)
  • Reload password (becomes wheels[new_environment])
Terminal window
# Copy from production but use H2 for testing
wheels env setup environment=test --base=production --dbtype=h2
# Copy from development but use different database name
wheels env setup environment=feature-branch --base=development --database=feature_test_db
  • development or dev - Local development
  • testing or test - Automated testing
  • staging - Pre-production testing
  • production or prod - Live environment
  • qa - Quality assurance
  • demo - Client demonstrations
Terminal window
wheels env setup environment=feature-auth --base=development
wheels env setup environment=performance-test --base=production --cache=false
wheels env setup environment=client-demo --base=staging

Best for traditional server deployments:

Terminal window
wheels env setup environment=prod --template=local --dbtype=mysql

Creates containerized environment:

Terminal window
wheels env setup environment=docker-dev --template=docker --dbtype=postgres

Generated docker-compose.docker-dev.yml:

version: '3.8'
services:
app:
build: .
ports:
- "8080:8080"
environment:
- WHEELS_ENV=docker-dev
- DB_TYPE=postgres
- DB_HOST=db
- DB_PORT=5432
- DB_NAME=wheels
- DB_USER=wheels
- DB_PASSWORD=wheels_password
volumes:
- .:/app
depends_on:
- db
db:
image: postgres:14
ports:
- "5432:5432"
environment:
POSTGRES_DB=wheels
POSTGRES_USER=wheels
POSTGRES_PASSWORD=wheels_password
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:

Creates VM-based environment:

Terminal window
wheels env setup environment=vm-test --template=vagrant --dbtype=mysql

The command provides environment-specific next steps:

  1. Switch to environment: wheels env switch [environment]
  2. Start server: box server start
  3. Access application at: http://localhost:8080
  1. Start Docker environment: docker-compose -f docker-compose.[environment].yml up
  2. Access application at: http://localhost:8080
  3. Stop environment: docker-compose -f docker-compose.[environment].yml down
  1. Start Vagrant VM: vagrant up
  2. Access application at: http://localhost:8080 or http://192.168.56.10:8080
  3. SSH into VM: vagrant ssh
  4. Stop VM: vagrant halt

Update config/environment.cfm to automatically detect environments:

<cfscript>
// Auto-detect environment based on server name
if (cgi.server_name contains "staging") {
this.env = "staging";
} else if (cgi.server_name contains "test") {
this.env = "testing";
} else if (cgi.server_name contains "demo") {
this.env = "demo";
} else if (cgi.server_name contains "localhost") {
this.env = "development";
} else {
this.env = "production";
}
</cfscript>

Load .env.[environment] files in Application.cfc:

<cfscript>
component extends="wheels.Controller" {
function config() {
// Load environment-specific variables
var envFile = expandPath(".env." & get("environment"));
if (fileExists(envFile)) {
loadEnvironmentFile(envFile);
}
}
private function loadEnvironmentFile(filePath) {
var lines = fileRead(arguments.filePath).listToArray(chr(10));
for (var line in lines) {
if (len(trim(line)) && !line.startsWith("##")) {
var parts = line.listToArray("=");
if (arrayLen(parts) >= 2) {
var key = trim(parts[1]);
var value = trim(parts[2]);
// Set as system property or use in configuration
set(lCase(key), value);
}
}
}
}
}
</cfscript>

After creating an environment, validate the setup:

Terminal window
# List all environments to verify creation
wheels env list
# Switch to the new environment
wheels env switch [environment]
# Test database connection
wheels test run --type=core
# Check configuration
wheels env current

Environment already exists:

Terminal window
wheels env setup environment=staging --force

Base environment not found:

Terminal window
# Check available environments
wheels env list
# Use correct base environment name
wheels env setup environment=test --base=development

Database connection issues:

  • Verify database credentials in .env.[environment]
  • Check database server is running
  • Validate port configuration

Permission issues:

  • Ensure write permissions for config directory
  • Check file system permissions
  • Use consistent, descriptive names
  • Avoid spaces and special characters
  • Follow team conventions
  • Use separate databases per environment
  • Document database naming conventions
  • Implement proper backup strategies
  • Use strong, unique reload passwords
  • Never commit sensitive credentials
  • Use environment variables for secrets
  • Start with a solid base environment
  • Document environment purposes
  • Test configurations thoroughly
  • local: Traditional server deployments
  • docker: Containerized applications
  • vagrant: Isolated development VMs
Terminal window
# Create testing environment for CI
wheels env setup environment=ci-test --base=production --dbtype=h2 --debug=false
# Create staging environment for deployment testing
wheels env setup environment=staging --base=production --dbtype=mysql --cache=true
Terminal window
# Create feature-specific environment
wheels env setup environment=feature-login --base=development --database=login_feature_db
# Create A/B testing environments
wheels env setup environment=variant-a --base=production --database=variant_a_db
wheels env setup environment=variant-b --base=production --database=variant_b_db
  1. Check syntax in generated settings.cfm
  2. Verify file permissions in config directory
  3. Review environment variable formats
  1. Verify database server is running
  2. Check credentials in .env.[environment]
  3. Test connection manually
  4. Review port configurations (remember H2 has no port)
  1. Check config/environment.cfm logic
  2. Verify server variables
  3. Test detection rules manually
  • Enable debugging for detailed information
  • Disable caching for hot reload
  • Use H2 for fast setup and teardown
  • Disable debugging for performance
  • Enable all caching options
  • Use optimized database configurations