Command Line Tools
wheels plugin init
wheels plugin init
Section titled “wheels plugin init”Initialize a new CFWheels plugin in the /plugins directory.
wheels plugin init <name> [--author=<name>] [--description=<text>] [--version=<version>] [--license=<type>]Parameters
Section titled “Parameters”| Parameter | Required | Type | Options | Default | Description |
|---|---|---|---|---|---|
name | Yes | string | - | - | Plugin name (will be prefixed with ‘wheels-’) |
author | No | string | - | "" | Plugin author name |
description | No | string | - | "" | Plugin description |
version | No | string | - | ”1.0.0” | Initial version number |
license | No | string | MIT, Apache-2.0, GPL-3.0, BSD-3-Clause, ISC, Proprietary | MIT | License type |
Description
Section titled “Description”The plugin init command creates a new CFWheels plugin following the standard CFWheels plugin structure. The plugin is created directly in your application’s /plugins directory and includes all necessary files to get started.
Features
Section titled “Features”- Creates plugin in
/pluginsdirectory - Follows CFWheels plugin conventions
- Includes
mixin="global"for framework-wide availability - Generates documentation files
- Includes test suite
- Ready for ForgeBox publishing
Examples
Section titled “Examples”Basic plugin initialization
Section titled “Basic plugin initialization”wheels plugin init myHelperOutput:
================================================== Initializing Wheels Plugin: wheels-myHelper==================================================
Creating plugin in /plugins/myHelper/...
[SUCCESS]: Plugin created successfully in /plugins/myHelper/
[INFO]: Files Created: - myHelper.cfc: Main plugin component - index.cfm: Documentation page - box.json: Package metadata - README.md: Project documentation
[INFO]: Next Steps: 1. Edit myHelper.cfc to add your plugin functions 2. Update index.cfm and README.md with usage examples 3. Test: wheels reload (then call your functions) 4. Publish: box login && box publishWith full metadata
Section titled “With full metadata”wheels plugin init authentication \ --author="Jane Smith" \ --description="Authentication and authorization system" \ --version="0.1.0" \ --license=MITQuick initialization
Section titled “Quick initialization”wheels plugin init api-tools --author="DevTeam"Generated Structure
Section titled “Generated Structure”The command creates the following structure in /plugins/pluginName/:
plugins/└── myHelper/ ├── box.json Package configuration ├── myHelper.cfc Main plugin component (mixin="global") ├── index.cfm Plugin documentation page ├── README.md Project documentation ├── .gitignore Git ignore file └── tests/ Test suite └── myHelperTest.cfc TestBox testsFile Templates
Section titled “File Templates”myHelper.cfc (Main Plugin Component)
Section titled “myHelper.cfc (Main Plugin Component)”component hint="wheels-myHelper" output="false" mixin="global" {
public function init() { this.version = "1.0.0"; return this; }
/** * Example function - Add your plugin methods here * * [section: Plugins] * [category: myHelper] * * @param1 Description of parameter */ public function myHelperExample(required string param1) { // Your plugin logic here return arguments.param1; }
}Key Features:
mixin="global"makes functions available everywhere in Wheels- Functions documented with Wheels doc format
[section: Plugins] - Version tracking via
this.version
index.cfm (Documentation Page)
Section titled “index.cfm (Documentation Page)”<h1>wheels-myHelper</h1><p>Plugin description</p>
<h3>Installation</h3><pre>wheels plugin install wheels-myHelper</pre>
<h3>Usage</h3><h4>Example Function</h4><pre>// Call the example functionresult = myHelperExample("test");</pre>box.json (Package Metadata)
Section titled “box.json (Package Metadata)”{ "name": "wheels-myHelper", "version": "1.0.0", "author": "Your Name", "slug": "wheels-myHelper", "type": "cfwheels-plugins", "keywords": "cfwheels,wheels,plugin", "homepage": "", "shortDescription": "Plugin description", "private": false}Development Workflow
Section titled “Development Workflow”1. Initialize Plugin
Section titled “1. Initialize Plugin”wheels plugin init myHelper --author="Your Name"2. Add Your Functions
Section titled “2. Add Your Functions”Edit /plugins/myHelper/myHelper.cfc and add your plugin methods:
public function formatCurrency(required numeric amount) { return dollarFormat(arguments.amount);}
public function slugify(required string text) { return lCase(reReplace(arguments.text, "[^a-zA-Z0-9]+", "-", "all"));}3. Update Documentation
Section titled “3. Update Documentation”Edit index.cfm and README.md with usage examples and function descriptions.
4. Test Your Plugin
Section titled “4. Test Your Plugin”wheels reloadThen in your Wheels application:
// Your functions are now available everywhereformatted = formatCurrency(1234.56); // Returns "$1,234.56"slug = slugify("My Blog Post"); // Returns "my-blog-post"5. Add Tests
Section titled “5. Add Tests”Edit /plugins/myHelper/tests/myHelperTest.cfc:
it("should format currency correctly", function() { var plugin = createObject("component", "myHelper").init(); var result = plugin.formatCurrency(1234.56); expect(result).toInclude("1,234");});Run tests:
box testbox run6. Publish to ForgeBox
Section titled “6. Publish to ForgeBox”cd plugins/myHelpergit initgit add .git commit -m "Initial commit"git remote add origin https://github.com/username/wheels-myHelper.gitgit push -u origin main
box loginbox publishPlugin Types
Section titled “Plugin Types”Common CFWheels plugin categories:
- Data Helpers - String manipulation, date formatting, validation
- Authentication - User authentication, session management, encryption
- API Tools - REST helpers, JSON formatting, API clients
- Database - Query helpers, soft delete, auditing
- UI Components - Form helpers, tables, pagination
- Email - Email formatting, templates, sending
- Caching - Cache management, warming, invalidation
- Testing - Test helpers, fixtures, mocking
Best Practices
Section titled “Best Practices”- Naming Convention: Always prefix with
wheels-(automatic) - Function Naming: Use clear, descriptive names
- Documentation: Document all public functions with Wheels format
- Testing: Include comprehensive test coverage
- Versioning: Follow semantic versioning (MAJOR.MINOR.PATCH)
- Dependencies: Minimize external dependencies
- Compatibility: Test with supported Wheels versions
How Plugin Loading Works
Section titled “How Plugin Loading Works”- Wheels scans
/pluginsdirectory on startup - Each plugin’s main CFC is instantiated
- With
mixin="global", functions become available in:- Controllers
- Models
- Views
- Other plugins
- Call
wheels reloadto reload plugins after changes
Error Handling
Section titled “Error Handling”Plugin Already Exists
Section titled “Plugin Already Exists”[ERROR] Plugin already exists
Plugin 'myHelper' already exists in /plugins folderSolution: Choose a different name or remove the existing plugin first.
No Wheels Application
Section titled “No Wheels Application”The command must be run from within a Wheels application directory.
- Plugin is created directly in
/pluginsdirectory - Plugin name automatically prefixed with
wheels-if not present - Folder name uses simple plugin name (without
wheels-prefix) - Use
mixin="global"to make functions available everywhere - Restart or reload Wheels after creating plugin
- Plugin functions documented with
[section: Plugins]format - Type must be
cfwheels-pluginsfor ForgeBox categorization
See Also
Section titled “See Also”- wheels plugin install - Install plugins from ForgeBox
- wheels plugin list - List installed plugins
- wheels reload - Reload application
- Developing Plugins - Full plugin development guide