Creating Components
You can scaffold cbwire components quickly using the commandbox-cbwire module.

Installing commandbox-cbwire

To get started open the CommandBox binary or enter the shell by typing box in your terminal or console. Then let's install our scaffolding module.
1
install commandbox-cbwire
Copied!

Creating Components

Let's create a Counter cbwire component that we will use to list our favorite movies.
1
cbwire create Counter
2
// Created /wires/Counter.cfc
3
// Created /views/wires/counter.cfm
4
// Created /tests/specs/integration/wires/CounterTest.cfc
Copied!
You can provide named arguments as well.
1
cbwire create name=Counter views=false
2
// Created /wires/Counter.cfc
3
// Created /tests/specs/integration/wires/CounterTest.cfc
Copied!
Below is the entire signature of arguments you can provide to the create command.
1
/**
2
* @name Name of the component to create without the .cfc.
3
* @actions Comma-delimited list of actions to generate.
4
* @views Generate a view for the cbwire component.
5
* @viewsDirectory Directory where your views are stored. Only used if views is set to true.
6
* @integrationTests Generate the integration test component
7
* @testsDirectory Your integration tests directory. Only used if integrationTests is true
8
* @directory Base directory to create your handler in and creates the directory if it does not exist. Defaults to 'handlers'.
9
* @description Component hint description.
10
* @open Opens the component (and test(s) if applicable) once generated.
11
**/
12
function run(
13
required string name,
14
string actions = "",
15
boolean views = true,
16
string viewsDirectory = "views/wires",
17
boolean integrationTests = true,
18
string testsDirectory = "tests/specs/integration/wires",
19
string directory = "wires",
20
string description = "I am a new cbwire component.",
21
boolean open = false
22
)
Copied!
Last modified 3mo ago